gradle-git-properties icon indicating copy to clipboard operation
gradle-git-properties copied to clipboard

Sometimes after a clean followed by clean build git.properties is not being generated

Open katelfox opened this issue 1 year ago • 4 comments

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.

katelfox avatar Jun 17 '24 16:06 katelfox

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'.

rsampaths16 avatar Jun 17 '24 18:06 rsampaths16

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 build or assemble without a clean does not result in the issue
  • Removing the git.properties file manually instead of calling clean does not result in the issue
    gradle 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 generateGitProperties directly instead of assemble or build does not result in the issue
  • Issue also occurs when gradle daemon is stopped in between
  • If main/resources is 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=false in gradle.properties the issue can't be observed

fabianlinz avatar Jul 23 '24 17:07 fabianlinz

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

delgurth avatar Jul 08 '25 21:07 delgurth

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

delgurth avatar Jul 09 '25 15:07 delgurth