graalvm / native-build-tools

Native-image plugins for various build tools
https://graalvm.github.io/native-build-tools/
Other
365 stars 57 forks source link

Compatibility issue with Gradle's configuration cache in `CollectReachabilityMetadata` task #427

Open CXwudi opened 1 year ago

CXwudi commented 1 year ago

Before reporting

Describe the bug The task collectReachabilityMetadata fails with Gradle's configuration cache enabled

To Reproduce Use Gradle 8.1, create a new application type Java project using gradle init, enable configuration cache, and add the native gradle plugin in the build.gradle.kts

Or use this minimal reproducible sample, test.zip

Run ./gradlew app:collectReachabilityMetadata

Expected behavior

The Gradle command should run successfully

Logs

🚀 ./gradlew app:collectReachabilityMetadata Encryption of the configuration cache is enabled. Calculating task graph as no configuration cache is available for tasks: app:collectReachabilityMetadata

FAILURE: Build failed with an exception.

25 problems were found storing the configuration cache, 5 of which seem unique.

See the complete report at file:///D:/coding-workspace/jvm-project/experiment/test/build/reports/configuration-cache/f08dxrrrchazgw6h5vryx7ytw/70mwsvs3jo0tz5pug7tk4107v/configuration-cache-report.html

Invocation of 'Task.project' by task ':app:collectReachabilityMetadata' at execution time is unsupported. Execution of task ':app:collectReachabilityMetadata' caused invocation of 'Task.project' by task ':app:compileJava' at execution time which is unsupported. Execution of task ':app:collectReachabilityMetadata' caused invocation of 'Task.convention' by task ':app:compileJava' at execution time which is unsupported. Execution of task ':app:collectReachabilityMetadata' caused invocation of 'Task.project' by task ':app:compileJava' at execution time which is unsupported.

BUILD FAILED in 3s 1 actionable task: 1 executed

Also, the configuration-cache-report.html file -> configuration-cache-report.zip

System Info:

Additional context This issue is similar but not too similar to #338, this compatibility issue comes from the CollectReachabilityMetadata task. This task is used by the bootJar task from the Spring Gradle plugin. So it actually breaks Spring plugin when configuration cache is enabled.

./gradlew build and ./gradlew nativeBuild are not affected, if we don't let them dependsOn the collectReachabilityMetadata task.

morki commented 1 year ago

I have the same issue, do you have any workaround except disabling configuration cache entirely?

CXwudi commented 1 year ago

@morki neither did I know

sgammon commented 1 year ago

we use these flags to get around those warnings (YMMV):

org.gradle.configuration-cache = true
org.gradle.configuration-cache.problems = warn
org.gradle.configuration-cache.stable = true

and, if necessary, in settings.gradle.kts:

enableFeaturePreview("STABLE_CONFIGURATION_CACHE")
sgammon commented 1 year ago

cc/ @morki @CXwudi

CXwudi commented 1 year ago

@sgammon Based on the documentation:

The configuration cache is automatically invalidated when inputs to the configuration phase change. However, certain inputs are not tracked yet, so you may have to manually invalidate the configuration cache when untracked inputs to the configuration phase change. This can happen if you ignored problems.

I wouldn't say org.gradle.configuration-cache.problems = warn is a long term solution

sgammon commented 1 year ago

@CXwudi certainly not, but my configuration cache is working so i figured i'd help with a WA. i was here to report my own configuration cache issue so even these flags don't completely solve it.