git-commit-id-maven-plugin icon indicating copy to clipboard operation
git-commit-id-maven-plugin copied to clipboard

Empty git.properties is generated in submodules when injectAllReactorProjects=true starting from 8.0.0

Open KTannenberg opened this issue 1 year ago • 0 comments

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

Re-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.properties

Are 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 - https://github.com/git-commit-id/git-commit-id-maven-plugin/commit/ee43e5702e51c1c33c9ff18b0afdc7092361182b

KTannenberg avatar Jun 13 '24 00:06 KTannenberg