Closed Fabian-K closed 3 years ago
Thanks for the report but I can't reproduce the behaviour you have described using a minimal build.gradle:
plugins {
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-dependencies:2.4.3'
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}
I've tried with both 6.8.1 as you used and also with 6.8.3. In both cases, the output is the following:
$ ./gradlew --configuration-cache --console=plain clean assemble
Configuration cache is an incubating feature.
Calculating task graph as configuration cache cannot be reused because file 'build.gradle' has changed.
> Task :clean
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :jar
> Task :assemble
BUILD SUCCESSFUL in 872ms
3 actionable tasks: 3 executed
Configuration cache entry stored.
Can you please provide some more detailed steps to reproduce the problem? Alternatively, could you attach to this issue a zip of the HTML report that Gradle generates?
Thanks for looking into this! I checked the differences between your minimal build.gradle and my project and it looks like this starts to fail once you add the kotlin plugin to the game (id "org.jetbrains.kotlin.jvm" version "1.4.31"
)
I did not expect that to make a difference... now I´m not sure if the behavior of the spring plugin changes once the kotlin plugin is there or if it not correctly claims that its io.spring.dependency-management fault 🙇♂️
Thanks. I've reproduced the problem now. The dependency management plugin reads the JVM's system properties to make them available to some embedded Maven code that resolves a dependency's effective pom. This is happening at execution time and my understanding is that the configuration cache only prohibits reading system properties at configuration time:
Plugins and build scripts should not read system properties directly using the Java APIs at configuration time
The problem can be reproduced with Gradle 6.8.3 and the following build.gradle
script:
plugins {
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "org.jetbrains.kotlin.jvm" version "1.4.31"
}
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-dependencies:2.4.3'
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}
def afterEvaluation = false
gradle.projectsEvaluated {
println "Evaluated"
afterEvaluation = true
}
allprojects { project ->
configurations.all { configuration ->
configuration.incoming.beforeResolve {
println "Resolving $configuration"
if (!afterEvaluation) {
throw new Exception("Configuration $configuration.name of project $project.name is being resolved at configuration time.")
}
}
}
}
$ ./gradlew --configuration-cache build
Configuration cache is an incubating feature.
Calculating task graph as no configuration cache is available for tasks: build
Evaluated
Resolving configuration ':kotlinCompilerClasspath'
Resolving configuration ':compileClasspath'
Resolving configuration ':kotlinCompilerPluginClasspath'
Resolving configuration ':annotationProcessor'
Resolving configuration ':testCompileClasspath'
Resolving configuration ':testAnnotationProcessor'
Resolving configuration ':testRuntimeClasspath'
FAILURE: Build failed with an exception.
* What went wrong:
Configuration cache problems found in this build.
280 problems were found storing the configuration cache, 31 of which seem unique.
- Plugin 'io.spring.dependency-management': read system property 'java.runtime.name'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'sun.boot.library.path'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'gopherProxySet'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'kotlin.environment.keepalive'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'file.encoding.pkg'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'user.country'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'sun.java.launcher'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'sun.os.patch.level'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'user.dir'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'java.awt.graphicsenv'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'java.endorsed.dirs'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'java.io.tmpdir'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'org.gradle.appname'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'user.variant'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
- Plugin 'io.spring.dependency-management': read system property 'sun.jnu.encoding'
See https://docs.gradle.org/6.8.1/userguide/configuration_cache.html#config_cache:requirements:undeclared_sys_prop_read
plus 16 more problems. Please see the report for details.
See the complete report at file:///Users/awilkinson/dev/temp/dmp-296/build/reports/configuration-cache/29t60872gqbxxv4b0etoznxta-4/configuration-cache-report.html
> Read system property 'java.runtime.name'
> Read system property 'sun.boot.library.path'
> Read system property 'gopherProxySet'
> Read system property 'kotlin.environment.keepalive'
> Read system property 'file.encoding.pkg'
* 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 1s
2 actionable tasks: 2 up-to-date
Configuration cache entry discarded with 280 problems.
The script verifies that evaluation has completed before any configurations are resolved so I'm pretty sure that the system properties are being read at execution time. If that's correct then it looks like there's either a bug in Gradle or the documentation is understating the restrictions on reading system properties. I'll seek some guidance from the Gradle team.
The undeclared system property reads are reported when calculating the task graph, after evaluation, before execution.
Task graph calculation visits the dependencies of task inputs here
which happen to be a by lazy
property in the Kotlin plugin that computes a classpath here - source
resolving that classpath triggers the spring dependency management plugin to resolve managed versions here
then the undeclared read gets reported at the usage site in the spring dependency management plugin here
Here's the configuration-cache-report.zip.
The attribution of the problem could be better and explain the chain.
Changing the script to report configurations resolved at task graph calculation time, before execution:
// ... snip
def ready = false
gradle.taskGraph.whenReady {
println "Task Graph Ready"
ready = true
}
allprojects { project ->
configurations.all { configuration ->
configuration.incoming.beforeResolve {
println "Resolving $configuration"
if (!ready) {
throw new Exception("$configuration of $project is being resolved at configuration time")
}
}
}
}
and running gradle build
shows that this is the kotlinCompilerClasspath
configuration that is resolved
* What went wrong:
Could not determine the dependencies of task ':compileKotlin'. |
> Failed to notify dependency resolution listener. |
> configuration ':kotlinCompilerClasspath' of root project 'spring-297' is being resolved at configuration time
I assume resolving that configuration triggers the spring dependency mangement plugin resolution rules.
I think this property on the Kotlin compilation task should be a proper lazy FileCollection
instead of a by lazy
List<File>
, that way the task dependencies visitation could keep the actual computation lazy.
In other words it looks like a problem in the Kotlin plugin to me.
Thank you, @eskatos.
I assume resolving that configuration triggers the spring dependency mangement plugin resolution rules
Yes, that's right. By default dependency management is configured "globally" (to all configurations) so resolution of kotlinCompilerClasspath
triggers it.
In other words it looks like a problem in the Kotlin plugin to me
That tallies with the problem only occurring when the Kotlin plugin's applied.
@Fabian-K can you please raise an issue with JetBrains and comment here with a link to it?
I found https://github.com/gradle/gradle/issues/13490 in general and https://youtrack.jetbrains.com/issue/KT-43605 specifically for kotlin
KT-43605 is for a different problem when using Gradle's configuration cache so I'd recommend raising a new issue for your specific problem. As @eskatos said above, the problem you're seeing is due to the computedCompilerClasspath
property.
Sorry for the delay, I opened https://youtrack.jetbrains.com/issue/KT-45834
Thank you, @Fabian-K.
Hi,
Gradle 6.8 has a new configuration cache feature that helps to improve build performance. Unfortunately, there are some restrictions on what plugins can use and the dependency-management-plugin is currently not compatible with this. It would be cool if it supports the configuration cache at some point :)
This should be reproducible with any sample project using gradle 6.8 and
gradlew --configuration-cache assemble
Thanks, Fabian