Saturday, November 5, 2022

Git Commit ID Maven Plugin

I found this plugin recently and absolutely love it: git-commit-id-maven-plugin

It generates a properties file (can select format, I use properties instead of json) under target/classes directory. 

Here is the setup I am using on my home demo project:



            
			
                pl.project13.maven
                git-commit-id-plugin
                4.9.10
                
                    
                        initialize
                        get-the-git-infos
                        
                            revision
                        
                    
                
                
                    ${project.basedir}/.git
                    git
                    false
                    true
                    ${project.build.outputDirectory}/git.properties
                    
                        ^git.build.(time|version)$
                        ^git.build.user.name$
                        ^git.commit.id$
                        ^git.commit.id.abbrev$
                    
                    properties
                    
                        false
                        false
                        -dirty
                    
                
            

The best way to make use of this plugin is to run it without the includeOnlyProperties section and see all the git information it generates.

From there, figure out which properties you actually want, and add the includeOnlyProperties section and specify just those properties.

No comments:

Post a Comment