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
Due to gradle/gradle#5510, compileJava may be executed unnecessarily when not using Gradle's daemon #14054
Comments
Thanks for the report. I don't think this is quite as simple has you have described. In my testing, Initial clean run, two tasks are executed as expected:
Run
Run
Repeat the run with
When Gradle's comparing task actions it uses the class loader for the action and the type name. It's Here is the name (as captured from the output of
And here's the name with
And the names from another run with
In this last build If
For reasons that I do not yet understand, the type names appear to change depending on the command line that's used to launch Gradle, and appears to do so predictably. We could work around this behaviour in the plugin by using anonymous inner classes rather than lambdas for task actions, but it feels like it would be better if that was addressed in Gradle so that all plugin authors can safely use lambdas for task actions. |
This is a known problem: gradle/gradle#5510. I'm going to see if I can create a minimal example that reproduces the problem. |
You're right, for some reason in my test runs I always had a recompilation, but now I ran Originally I used the following to see that the lambda changes:
|
Irrespective of a change in Gradle, we should probably do something about this in our plugin. If we don't, users on current versions of Gradle will still be affected by the problem. |
Thanks for swapping out the lambdas. I'm looking forward to this being released. |
spring-boot-gradle-plugin applied to a project build with no-daemon Gradle breaks incremental build - causes a retriggering of
compileJava
with every runSteps to reproduce:
gradlew --no-daemon clean assemble
gradlew --no-daemon testClasses
Expected behaviour
Task
compileJava
is UP-TO-DATE as nothing has changed that should trigger recompilation.Actual behaviour
Task
compileJava
is run because, as Gradle prints, "Task ':compileJava' has additional actions that have changed"Probable cause
During up-to-date checks Gradle compares task's previously known actions with current actions for equality (see
org.gradle.api.internal.changedetection.rules.TaskTypeTaskStateChanges
). Spring boot'sorg.springframework.boot.gradle.plugin.JavaPluginAction
configures a JavaCompile task inconfigureAdditionalMetadataLocations
with an action using a labda.When building with a daemon that configuration probably happens once and in JavaCompile task's actions we can see the same lambda instance, which makes it equal and up-to-date check passes. When executing without a daemon another run has a different lambda instance and it fails the equality check.
In our project we have multiple steps configured as separate gradle runs and each of them recompiles the whole project.
Versions
Gradle 4.9
Spring Boot 2.0.4.RELEASE
The text was updated successfully, but these errors were encountered: