Sometimes after a clean followed by clean build git.properties is not being generated
Using version 2.4.2 with a multi module project. Gradle version 8.6.
When I do a clean build followed by another clean build git.properties is not being regenerated (running it a third time and it does get generated). The gradle task says FROM-CACHE when this happens.
I'm not sure how to troubleshoot this further.
Am facing the same issue for the same plugin & Gradle version.
Observation, the git.properties is build alternatively for every clean & build.
The following pattern is observed. Note that I'm not sure if the it's the first build that's skipping, or the second one.
...
clean
build -> generated
clean
build -> not generated
clean
build -> generated
clean
build -> not generated
...
Build log when git.properties isn't generated
Executing 'build'...
> Task :generateEffectiveLombokConfig FROM-CACHE
> Task :compileJava FROM-CACHE
> Task :generateGitProperties FROM-CACHE
> Task :processResources
> Task :classes
> Task :resolveMainClassName
> Task :bootJar
> Task :bootStartScripts
> Task :bootDistTar
> Task :bootDistZip
> Task :jar SKIPPED
> Task :startScripts
> Task :distTar
> Task :distZip
> Task :assemble
> Task :generateTestEffectiveLombokConfig FROM-CACHE
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :check UP-TO-DATE
> Task :build
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 7s
13 actionable tasks: 9 executed, 4 from cache
Execution finished 'build'.
Build log when git.properties is generated
Executing 'build'...
> Task :generateEffectiveLombokConfig FROM-CACHE
> Task :compileJava FROM-CACHE
> Task :generateGitProperties FROM-CACHE
> Task :processResources
> Task :classes
> Task :resolveMainClassName
> Task :bootJar
> Task :bootStartScripts
> Task :bootDistTar
> Task :bootDistZip
> Task :jar SKIPPED
> Task :startScripts
> Task :distTar
> Task :distZip
> Task :assemble
> Task :generateTestEffectiveLombokConfig FROM-CACHE
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :check UP-TO-DATE
> Task :build
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 5s
13 actionable tasks: 9 executed, 4 from cache
Execution finished 'build'.
We are facing the same issue. When downgrading to Gradle 8.5 it's works again, but with 8.6 up to the last night build 8.10-20240723003427+0000 it behaves as described above.
Workaround for now:
generateGitProperties {
outputs.upToDateWhen { false }
}
alternative: turn of caching e.g. via org.gradle.caching=false in gradle.properties
Reproducible on ever second/ third execution of clean assemble (as also described above)
(you can find a minimal example at https://github.com/fabianlinz/2024_07_git_properties_issue):
gradle clean assemble --console=plain
ls my-module/build/resources/main/git.properties => file exists
gradle clean assemble --console=plain
ls my-module/build/resources/main/git.properties => file DOES NOT exists
gradle clean assemble --console=plain
ls my-module/build/resources/main/git.properties => file exists
gradle clean assemble --console=plain
ls my-module/build/resources/main/git.properties => file DOES NOT exists
(and so on)
Some further observations
- Just executing
buildorassemblewithout acleandoes not result in the issue - Removing the
git.propertiesfile manually instead of callingcleandoes not result in the issuegradle assemble --console=plain ls my-module/build/resources/main/git.properties => file exists rm my-module/build/resources/main/git.properties gradle my-module:assemble --console=plain ls my-module/build/resources/main/git.properties => file still exists => for some reason deleting the file is not the same as clean - Calling
generateGitPropertiesdirectly instead ofassembleorbuilddoes not result in the issue - Issue also occurs when gradle daemon is stopped in between
- If
main/resourcesis completely empty the issue can't be observed (so this might be some interference with Gradles java plugin?) - If caching is turned off e.g. via
org.gradle.caching=falseingradle.propertiesthe issue can't be observed
Thank you @fabianlinz for your example project. I've tuned it down a bit more and used git bisect to find the commit that caused this. Unfortunately that didn't give me a clue on how to fix this, so in the end I raised an issue with gradle: https://github.com/gradle/gradle/issues/34177
We got help and it seems that my assumption that's a bug in gradle is wrong. The way this plugin interacts with the processResources task seems to be wrong. The quick fix is provided in this comment:
https://github.com/gradle/gradle/issues/34177#issuecomment-3051970053