Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Gradle 6.6 #153

Closed
radarsh opened this issue Jun 29, 2020 · 3 comments · Fixed by #167
Closed

Upgrade to Gradle 6.6 #153

radarsh opened this issue Jun 29, 2020 · 3 comments · Fixed by #167
Assignees

Comments

@radarsh
Copy link
Owner

radarsh commented Jun 29, 2020

Description

Upgrade to Gradle 6.6

@radarsh
Copy link
Owner Author

radarsh commented Jun 29, 2020

Blocked by gradle/gradle#13614

@dsvensson
Copy link

dsvensson commented Aug 13, 2020

gradle 6.6 released, and with the new --configuration-cache this plugin causes:

- plugin 'com.adarshr.test-logger': read system property 'sun.jnu.encoding'
  See https://docs.gradle.org/6.6/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read

Looks like a trivial fix. Have to lookup the overrides specifically rather than searching for them like today in getOverrides.

@dsvensson
Copy link

dsvensson commented Aug 25, 2020

Trying to fix (wild guesses here, never done any plugin development - nor groovy) that part results in the following error on the second execution after establishing the cache:

./gradlew test --configuration-cache
Configuration cache is an incubating feature.
Reusing configuration cache.

FAILURE: Build failed with an exception.

* What went wrong:
Could not load the value of field `testListenerBroadcaster` of task `:test` of type `org.gradle.api.tasks.testing.Test`.
> com.adarshr.gradle.testlogger.logger.TestLoggerWrapper

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 451ms
Configuration cache entry reused.
Crude diff to get rid of the undeclared_sys_prop_read warning:
diff --git a/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerExtension.groovy b/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerExtension.groovy
index e46768e..2a71e06 100644
--- a/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerExtension.groovy
+++ b/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerExtension.groovy
@@ -3,6 +3,7 @@ package com.adarshr.gradle.testlogger
 import com.adarshr.gradle.testlogger.theme.ThemeType
 import groovy.transform.CompileStatic
 import org.gradle.api.logging.LogLevel
+import org.gradle.api.provider.ProviderFactory
 import org.gradle.api.tasks.testing.logging.TestLogging
 
 import static com.adarshr.gradle.testlogger.theme.ThemeType.STANDARD
@@ -185,31 +186,35 @@ class TestLoggerExtension {
         this
     }
 
-    TestLoggerExtension applyOverrides(Map<String, String> overrides) {
-        override(overrides, 'theme', ThemeType)
-        override(overrides, 'showExceptions', Boolean)
-        override(overrides, 'showCauses', Boolean)
-        override(overrides, 'showStackTraces', Boolean)
-        override(overrides, 'showFullStackTraces', Boolean)
-        override(overrides, 'slowThreshold', Long)
-        override(overrides, 'showSummary', Boolean)
-        override(overrides, 'showStandardStreams', Boolean)
-        override(overrides, 'showPassedStandardStreams', Boolean)
-        override(overrides, 'showSkippedStandardStreams', Boolean)
-        override(overrides, 'showFailedStandardStreams', Boolean)
-        override(overrides, 'showPassed', Boolean)
-        override(overrides, 'showSkipped', Boolean)
-        override(overrides, 'showFailed', Boolean)
-        override(overrides, 'showSimpleNames', Boolean)
+    TestLoggerExtension applyOverrides(ProviderFactory providers) {
+        override(providers, 'theme', ThemeType)
+        override(providers, 'showExceptions', Boolean)
+        override(providers, 'showCauses', Boolean)
+        override(providers, 'showStackTraces', Boolean)
+        override(providers, 'showFullStackTraces', Boolean)
+        override(providers, 'slowThreshold', Long)
+        override(providers, 'showSummary', Boolean)
+        override(providers, 'showStandardStreams', Boolean)
+        override(providers, 'showPassedStandardStreams', Boolean)
+        override(providers, 'showSkippedStandardStreams', Boolean)
+        override(providers, 'showFailedStandardStreams', Boolean)
+        override(providers, 'showPassed', Boolean)
+        override(providers, 'showSkipped', Boolean)
+        override(providers, 'showFailed', Boolean)
+        override(providers, 'showSimpleNames', Boolean)
 
         this
     }
 
-    private void override(Map<String, String> overrides, String name, Class type) {
-        if (overrides.containsKey(name)) {
+    private void override(ProviderFactory providers, String name, Class type) {
+        def property = providers
+            .systemProperty("${TestLoggerPlugin.EXTENSION_NAME}.${name}" as String)
+            .forUseAtConfigurationTime()
+
+        if (property.isPresent()) {
             String method = Enum.isAssignableFrom(type) ? 'fromName' : 'valueOf'
 
-            setProperty(name, type.invokeMethod(method, overrides[name]))
+            setProperty(name, type.invokeMethod(method, property.get()))
         }
     }
 }
diff --git a/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerPlugin.groovy b/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerPlugin.groovy
index 9faba2e..674dee5 100644
--- a/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerPlugin.groovy
+++ b/src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerPlugin.groovy
@@ -9,7 +9,7 @@ import org.gradle.api.tasks.testing.Test
 @CompileStatic
 class TestLoggerPlugin implements Plugin<Project> {
 
-    private static final String EXTENSION_NAME = 'testlogger'
+    public static final String EXTENSION_NAME = 'testlogger'
 
     @Override
     void apply(Project project) {
@@ -44,14 +44,6 @@ class TestLoggerPlugin implements Plugin<Project> {
             .undecorate()
             .reactTo(test.testLogging)
             .combine(projectExtension)
-            .applyOverrides(overrides)
-    }
-
-    private static Map<String, String> getOverrides() {
-        (System.properties as Map<String, String>).findAll { key, value ->
-            key.startsWith "${EXTENSION_NAME}."
-        }.collectEntries { key, value ->
-            [(key.replace("${EXTENSION_NAME}.", '')): value]
-        } as Map<String, String>
+            .applyOverrides(test.project.providers)
     }
 }

...and commenting out jacoco, build scans, and the overrides test, and bumping to 6.6

@radarsh radarsh changed the title Upgrade to Gradle 6.5 Upgrade to Gradle 6.6 Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants