镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Closed

Description

@KTannenberg

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 - ee43e57

Activity

  1. nikita-rogovyi commented on Jul 1, 2024

    @nikita-rogovyi

    the same issue after update from boot 3.2 to 3.3

  2. TheSnoozer commented on Jul 1, 2024

    @TheSnoozer
    Collaborator

    Thanks for the detailed report! Likely related to #700

  3. KTannenberg commented on Jul 1, 2024

    @KTannenberg
    Author

    the same issue after update from boot 3.2 to 3.3

    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

  4. added a commit that references this issue on Jul 2, 2024
  5. TheSnoozer commented on Jul 2, 2024

    @TheSnoozer
    Collaborator

    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:

    properties = new Properties(contextProperties);

    instead of the previous

    properties = contextProperties;

    The contextProperties are 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 the properties variable.

    With a

    properties = new Properties(contextProperties);

    the properties seem essentially empty (contextProperties are still correctly populated):

    [INFO] === GitCommitIdPlugin.runPlugin(#
    #Tue Jul 02 17:45:23 CEST 2024
    )
    

    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:

    properties = new Properties();
    properties.putAll(contextProperties);

    which IMHO should also do the trick.

    Thanks again for the report!

  6. added a commit that references this issue on Jul 2, 2024
  7. added this to the 9.0.1 milestone on Jul 2, 2024
  8. TheSnoozer commented on Jul 2, 2024

    @TheSnoozer
    Collaborator
  9. KTannenberg commented on Jul 2, 2024

    @KTannenberg
    Author

    Thanks @TheSnoozer, can confirm that fix works:

    mvn clean initialize -Dgit-commit-id-maven-plugin.version=9.0.1 && cat commons/target/classes/git.properties job/target/classes/git.properties | grep git.commit.id
    
    ...
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  2.788 s
    [INFO] Finished at: 2024-07-02T19:04:46+01:00
    [INFO] ------------------------------------------------------------------------
    git.commit.id=b509b387017ec6dbc52052fbb412698f44c5b566
    git.commit.id.abbrev=b509b38
    git.commit.id.describe=1.7.0-2-gb509b38
    git.commit.id.describe-short=1.7.0-2
    git.commit.id=b509b387017ec6dbc52052fbb412698f44c5b566
    git.commit.id.abbrev=b509b38
    git.commit.id.describe=1.7.0-2-gb509b38
    git.commit.id.describe-short=1.7.0-2
    
  10. TheSnoozer commented on Jul 2, 2024

    @TheSnoozer
    Collaborator

    Great, thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions