Skip to content

Question: How to suppress log output "[INFO] Tag refs" ? #624

Description

@paulwwisl

Describe the idea (required)

Problem, we use v4.9 of git-commit-id-maven-plugin

Log output for [INFO] Tag refs is huge, about 2-4 screens

[INFO] --- git-commit-id:4.9.10:revision (default) @ server ---
....
[INFO] Tag refs [[Ref[refs/tags/1.0.1=3254ae156395007f2805cca386f4b2d65483ceb1(-1)], Ref[refs/tags/5.0.4=14f9d127049117fec941d85dba2c765076762ce6(-1)], Ref[refs/tags/8.8.12=8605346b6e5a49d592b6aab887eb1ed5c5c2aaeb(-1)], Ref[refs/tags/banking-redirect-testing=379a21743cca4465e2eb5f3968f00535a2be534b(-1)], Ref[refs/tags/deploy-postfach-stage20201104=7bbc0efb1e5494bbb95df1a7de6fae5a73e5cbb1(-1)], Ref[refs/tags/deploy-postfach-stage20201210=154f7844665a26ab9f26976a03e8d08ed2c1cd86(-1)], Ref[refs/tags/deploy-rzwwi-test-fgstage=7ef1e17eddd21b361853f4de7620528b4b2a484c(-1)], Ref[refs/tags/experiment/TF-5080-baxit-worker-refreshlogic=8dd3fa54131a33d52e20c892375c76476667bc18(-1)], Ref[refs/tags/experiment/TF...

How to suppress specific log output of maven this plugin?

Tell us about the expected behaviour (required)

Hopefully there is a way to configer how verbose is log output

Context (optional)

https://stackoverflow.com/questions/76275003/how-to-suppress-specific-log-output-of-maven-git-commit-id-maven-plugin-plugin

Activity

  1. TheSnoozer commented on May 17, 2023

    @TheSnoozer
    Collaborator

    Try <verbose>false</verbose> or paste the config of the plugin.

  2. TheSnoozer commented on May 18, 2023

    @TheSnoozer
    Collaborator

    Please reopen, with a full configuration of the plugin, if still an issue.

  3. added this to the 7.0.0 milestone on May 18, 2023
  4. paulwwisl commented on May 30, 2023

    @paulwwisl
    ContributorAuthor

    Thanks that worked for me
    But it actually suppressed all output

    And there seems to be no docs for the option,
    other then sources

    https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/master/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java#L127-L146

  5. TheSnoozer commented on May 30, 2023

    @TheSnoozer
    Collaborator

    Unfortunately there is no option to surpress "just" the Ref-Output. I also feel that would be too overkill (the plugin already has too many options IMHO). Either you get it all (depending on verbosity you have selected) or nothing. Just curious: In what log would you be interested?

    Indeed there is no longer any dedicated "doc" available. I recently moved all the documentation from a dedicated doc to the java code as javadoc. It felt like a pain to maintain a doc that is not close to the source and essentially duplicate all the blah blah written in the doc into javadoc, duplicating explanations. If you prefer a stand-alone doc please refer to older version https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/version5.x/docs/using-the-plugin.md.

  6. added a commit that references this issue on May 30, 2023
  7. TheSnoozer commented on May 30, 2023

    @TheSnoozer
    Collaborator

    I reviewed the code again and indeed when using the default <useNativeGit>false</useNativeGit> the code is chattier and outputs all the "ref" information. When using the native git binary with <useNativeGit>true</useNativeGit> the plugin will log way less information making the logging a bit inconsistent with the default info log level. As a result I have reduced the log level for some perhaps all chatty info messages. That means they are not gone, but not visible by default.

    For the time being you have two options to not see them:
    1)

    <verbose>false</verbose>
    <useNativeGit>true</useNativeGit>

    Eventually in 7.0.0 the ref messages will only be logged on the debug level making them only visible when you tell maven to make them visible.

  8. paulwwisl commented on May 31, 2023

    @paulwwisl
    ContributorAuthor

    For v4.9.0 in use, for sure, verbose=false is not default

    That is strange, as line
    @Parameter(defaultValue = "false")
    is shown as 8 years old by git blame,
    so it should have been known for long time.

  9. paulwwisl commented on May 31, 2023

    @paulwwisl
    ContributorAuthor

    Unfortunately there is no option to surpress "just" the Ref-Output.

    Yes, that was my initial idea, but setting verbose=false is good enough

  10. TheSnoozer commented on May 31, 2023

    @TheSnoozer
    Collaborator

    Mhh weird, verbose=false should be the default since "forever" (as you mentioned the git blame points to a change 8 years!!! ago).

    Maybe try the latest version

    <dependency>
        <groupId>io.github.git-commit-id</groupId>
        <artifactId>git-commit-id-maven-plugin</artifactId>
        <version>5.0.1</version>
    </dependency>
    

    otherwise it sounds like some weird maven bug....what maven version are you using? What OS?

  11. paulwwisl commented on Jun 6, 2023

    @paulwwisl
    ContributorAuthor
    $ mvn -V
    Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
    Maven home: /opt/homebrew/Cellar/maven/3.9.1/libexec
    Java version: 1.8.0_362, vendor: Amazon.com Inc., runtime: /Users/user/Library/Java/JavaVirtualMachines/corretto-1.8.0_362-1/Contents/Home/jre
    Default locale: en_DE, platform encoding: UTF-8
    OS name: "mac os x", version: "13.4", arch: "aarch64", family: "mac"
    

    We use v4.9.10, that is actually defined by Spring Boot dependencies 2.7.7
    https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/2.7.7

                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <configuration>
                        <generateGitPropertiesFile>true</generateGitPropertiesFile>
                        <!-- We don't want the plugin to fetch anything. Just use the local .git folder mkay?-->
                        <offline>true</offline>
                    </configuration>
                </plugin>

    and it produces 3-4 screens of output

    [INFO] --- clean:3.2.0:clean (default-clean) @ srv ---
    [INFO] Deleting /Users/pverest/Workspaces/ws/srv/target
    [INFO] 
    [INFO] --- dependency:3.3.0:copy (default) @ srv ---
    [INFO] 
    [INFO] --- git-commit-id:4.9.10:revision (default) @ srv ---
    [INFO] dotGitDirectory /Users/pverest/Workspaces/ws/srv/.git
    [INFO] Collected git.build.user.name with value __
    [INFO] Collected git.build.user.email with value __
    [INFO] Collected git.branch with value dev
    [INFO] --always = true
    [INFO] --dirty = -dirty
    [INFO] --abbrev = 7
    [INFO] Tag refs [[Ref[refs/tags/1.0.1=3254ae156395007f2805cca386f4b2d65483ceb1(-1)], Ref[refs/tags/5.0.4=14f9d127049117fec941d85dba2c765076762ce6(-1)], Ref[refs/tags/8.8.12=8605346b6e5a49d592b6aab887eb1ed5c5c2aaeb(-1)], Ref[refs/tags/ban
    
    many-many lines here
    

    And after I switch to newer version

                <plugin>
                    <groupId>io.github.git-commit-id</groupId>
                    <artifactId>git-commit-id-maven-plugin</artifactId>
                    <version>5.0.1</version>
                    <configuration>
                        <generateGitPropertiesFile>true</generateGitPropertiesFile>
                        <!-- We don't want the plugin to fetch anything. Just use the local .git folder mkay?-->
                        <offline>true</offline>
                    </configuration>
                </plugin>
    

    I don't see that the plugin is executed at all

    [INFO] --- clean:3.2.0:clean (default-clean) @ srv ---
    [INFO] Deleting /Users/pverest/Workspaces/ws/srv/target
    [INFO] 
    [INFO] --- dependency:3.3.0:copy (default) @ srv ---
    [INFO] 
    [INFO] --- spring-boot:2.7.7:build-info (build-info) @ srv ---
    [INFO] 
    

    ( I did not check correctness, just log output )


    P.S. OK, found in effective pom.xml

    <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>build-helper-maven-plugin</artifactId>
              <version>3.3.0</version>
            </plugin>
            <plugin>
              <groupId>org.flywaydb</groupId>
              <artifactId>flyway-maven-plugin</artifactId>
              <version>8.5.13</version>
            </plugin>
            <plugin>
              <groupId>pl.project13.maven</groupId>
              <artifactId>git-commit-id-plugin</artifactId>
              <version>4.9.10</version>
              <executions>
                <execution>
                  <goals>
                    <goal>revision</goal>
                  </goals>
                  <configuration>
                    <verbose>true</verbose>
                    <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>/Users/user/Workspaces/ws/srv/target/classes/git.properties</generateGitPropertiesFilename>
                  </configuration>
                </execution>
              </executions>
              <configuration>
                <verbose>true</verbose>
                <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
                <generateGitPropertiesFile>true</generateGitPropertiesFile>
                <generateGitPropertiesFilename>/Users/user/Workspaces/ws/srv/target/classes/git.properties</generateGitPropertiesFilename>
              </configuration>
            </plugin>

    So the verbose=true comes from <pluginManagement> of spring-boot-starter-parent 2.7.7
    https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/2.7.7

    And if using latest GAV, then those managed config is not applied.

    So I would stay on current version, just to make verbose=false back again.

  12. paulwwisl commented on Jun 6, 2023

    @paulwwisl
    ContributorAuthor

    FYI

    The latest Spring Boot 3.1.0

    defines

            <plugin>
              <groupId>io.github.git-commit-id</groupId>
              <artifactId>git-commit-id-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>revision</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <verbose>true</verbose>
                <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
                <generateGitPropertiesFile>true</generateGitPropertiesFile>
                <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
              </configuration>
            </plugin>
    

    and managed version 5.0.0

  13. TheSnoozer commented on Jun 6, 2023

    @TheSnoozer
    Collaborator

    Thanks for the additional input. I'm now confused. I don't really work in the spring-boot eco system, so please bare with me.

    I see that you posted about two different poms:

    1. spring-boot-starter:
      Old version: https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.7.7/spring-boot-starter-parent-2.7.7.pom defines
    <plugin>
    <groupId>pl.project13.maven</groupId>
    <artifactId>git-commit-id-plugin</artifactId>
    <executions>
    <execution>
    <goals>
    <goal>revision</goal>
    </goals>
    </execution>
    </executions>
    <configuration>
    <verbose>true</verbose>
    <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
    <generateGitPropertiesFile>true</generateGitPropertiesFile>
    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
    </configuration>
    </plugin>

    New-Version https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-parent/3.1.0/spring-boot-starter-parent-3.1.0.pom defines:

    <plugin>
    <groupId>io.github.git-commit-id</groupId>
    <artifactId>git-commit-id-maven-plugin</artifactId>
    <executions>
    <execution>
    <goals>
    <goal>revision</goal>
    </goals>
    </execution>
    </executions>
    <configuration>
    <verbose>true</verbose>
    <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
    <generateGitPropertiesFile>true</generateGitPropertiesFile>
    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
    </configuration>
    </plugin>

    in both cases the plugin should get executed with <verbose>true</verbose>.

    Now the case where you mentioned the plugin is not executed at all is yet another pom:
    https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.7.7/spring-boot-dependencies-2.7.7.pom that defines:

    <plugin>
    <groupId>pl.project13.maven</groupId>
    <artifactId>git-commit-id-plugin</artifactId>
    <version>${git-commit-id-plugin.version}</version>
    </plugin>

    I would say I would not expect the plugin to be executed by this definition. This doesn't define a phase, or any goals. It simply states what plugin you want to use, when it's referenced. If you will you declare the configuration of the plugin, but no execution whatsoever.

    I'm also not so sure what you are asking me now:
    The above definition includes a <verbose>true</verbose> so verbose output is generated. Do you want a command-line switch to disable it? Do you want a release to get rid of the excessive log output? Note that I'm not a maintainer of spring. So even if I cut a release it may take a while until it becomes available to you...

  14. paulwwisl commented on Jun 7, 2023

    @paulwwisl
    ContributorAuthor

    in both cases the plugin should get executed with true.

    Yes, exactly, all Java developers with Spring Boot will get verbose=true config by default (if just this plugin is used)

    I would say I would not expect the plugin to be executed by this definition.

    Yes, those lines from spring-boot-dependencies only defines version

    I'm also not so sure what you are asking me now:

    The initial problem as said was resolved above with configuring verbose=false
    Now with this longer description for what Spring developers have made as default for Java developers with Spring Boot,
    I think some warning in docs, e.g. README, would save time for this plugin users, as defaults and execution are not is affected.

    Suggested docs section:

    Note for Spring Boot users

    Spring Boot defines configuration in spring-boot-starter-parent
    and default (mananged) version in spring-boot-dependencies
    that make usage of this plugin easier within Spring Boot opinion
    https://docs.spring.io/spring-boot/docs/3.1.0/reference/html/howto.html#howto.build.generate-git-info

    Because this plugin groupId changed (from pl.project13.maven to io.github.git-commit-id,
    and Spring Boot migrated between 2.7 and 3.1
    TODO check exact version point),
    you should be careful to either follow carefully Spring Boot Howto Build
    or understand/check effective pom.xml

  15. TheSnoozer commented on Jun 7, 2023

    @TheSnoozer
    Collaborator

    Mhh users can configure their plugin to their liking.
    If someone prefers the <verbose>true</verbose> it's not my business to argue against it ;-)

    The latest documentation has a warning that the verbose mode may contain sensitive information (e.g. https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/master/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java#L127). However since I lowered the log level I feel this is all should and can do. Certainly those extra ref logs will go away once spring boot adopts the 7.0.0 version.

    I'm just a maintainer of a very old maven project and not spring boot :-) If you want extra warnings somewhere in the (spring boot) documentation, please follow-up with spring boot, or feel free to create a MR. Happy to review things.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions