Repository navigation
Empty git.properties is generated in submodules when injectAllReactorProjects=true starting from 8.0.0 #754
Description
Describe the bug (required)
When running git-commit-id-plugin on a multi-module maven project with a parent pom and injectAllReactorProjects set to true, all generated git.properties in submodules will end up with no content.
This bug affects versions 8.0.0+ of plugin, version 7.0.0 is the latest not affected one.
Tell us about your plugin configuration (required)
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>${git-commit-id-maven-plugin.version}</version>
<configuration>
<prefix>git</prefix>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>
<dateFormatTimeZone>UTC</dateFormatTimeZone>
<dotGitDirectory>${maven.multiModuleProjectDirectory}/.git</dotGitDirectory>
<gitDescribe>
<skip>false</skip>
<always>true</always>
</gitDescribe>
<injectAllReactorProjects>true</injectAllReactorProjects>
<skipPoms>false</skipPoms>
<!-- Clear defaults from spring-boot-starter-parent -->
<verbose>true</verbose>
<generateGitPropertiesFile>false</generateGitPropertiesFile>
<generateGitPropertiesFilename>NONE</generateGitPropertiesFilename>
</configuration>
<executions>
<!-- Disable default execution from spring-boot-starter-parent -->
<execution>
<id>default</id>
<phase/>
</execution>
<!-- Collect git information once for multi-module projects to speed up builds -->
<execution>
<id>git-info-collect</id>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
<configuration>
<skipPoms>false</skipPoms>
<runOnlyOnce>true</runOnlyOnce>
</configuration>
</execution>
<execution>
<id>git-info-properties</id>
<goals>
<goal>revision</goal>
</goals>
<configuration>
<format>properties</format>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
</configuration>
</execution>
</executions>
</plugin>Tell us about the Plugin version used (required)
7.0.0, 8.0.2, 9.0.0
Tell us about the Maven version used (required)
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /home/john.doe/.sdkman/candidates/maven/current
Java version: 17.0.11, vendor: BellSoft, runtime: /home/john.doe/.sdkman/candidates/java/17.0.11-librca
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.146.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"
Steps to Reproduce (required)
Clone repository
Run maven initialize and check contents of generated git.properties files
mvn clean initialize
# non-empty diff as module1's file only contains header comment
diff -u target/classes/git.properties module1/target/classes/git.propertiesRe-run with version 7.0.0 of plugin
mvn clean initialize -Dgit-commit-id-maven-plugin.version=7.0.0
# no differences between the files
diff -u target/classes/git.properties module1/target/classes/git.propertiesAre there any stacktraces or any error messages? (required)
WARNING You may NOT want to paste all the output that is produced with verbose publicly,
since it MAY contain information you deem sensitive.
Review this CAREFULLY before posting your issue!
mvn clean deploy
// ????Is there a (public) project where this issue can be reproduced? (optional)
https://github.com/KTannenberg/git-commit-id-example
Your Environment (optional)
Ubuntu 22.04.4 LTS running inside WSL2 on Windows 11
Running same steps natively on Windows 11 reproduces same bug
Context (optional)
Looking through diff between 7.0.0 and 8.0.0 I think that this commit might be a culprit - ee43e57
Activity
nikita-rogovyi commentedon Jul 1, 2024
the same issue after update from boot 3.2 to 3.3
TheSnoozer commentedon Jul 1, 2024
Thanks for the detailed report! Likely related to #700
KTannenberg commentedon Jul 1, 2024
Spring Boot 3.2.x uses version 6.0.0 of this plugin, Spring Boot 3.3.0 switches to 8.0.2 of the plugin - spring-projects/spring-boot@53f8504
#754: Fix an issue where empty git.properties had been generated in s…
TheSnoozer commentedon Jul 2, 2024
Thanks again for the reproducer and indeed the problem seems to be related to the changes done in ee43e57.
The issue seems to boil down to using:
instead of the previous
The
contextPropertiesare the properties that had been generated by a potential previous run and are essentially still correctly populated. The plugin will then essentially dump whatever was specified as thepropertiesvariable.With a
the properties seem essentially empty (contextProperties are still correctly populated):
I must admit that is a bit of a strange behaviour and when reading the javadoc of the properties class I still wouldn't expect such behaviour. Defaults for me sound like they should be there, but secrectly disappear....
My fix from https://github.com/git-commit-id/git-commit-id-maven-plugin/pull/760/files would propose to run:
which IMHO should also do the trick.
Thanks again for the report!
Merge pull request #760 from git-commit-id/754
TheSnoozer commentedon Jul 2, 2024
Now released: https://github.com/git-commit-id/git-commit-id-maven-plugin/releases/tag/v9.0.1
KTannenberg commentedon Jul 2, 2024
Thanks @TheSnoozer, can confirm that fix works:
TheSnoozer commentedon Jul 2, 2024
Great, thanks for the feedback!