Include git commit hash in jar version

后端 未结 2 1863
慢半拍i
慢半拍i 2021-02-01 18:56

I\'m using maven and my goal is to include the git commit hash in the version number. Something like : 1.1.{git_hash}.

I\'m trying to follow this tutorial.

Q: i

2条回答
  •  情书的邮戳
    2021-02-01 19:33

    The above accepted answer didn't work for me. I found the link https://dzone.com/articles/maven-git-commit-id-plugin, from where I copied the plugin code below. It worked first time for me. I now have the git.properties file automatically included in my target JAR file. Very useful for tracking.

    
    pl.project13.maven
    git-commit-id-plugin
    2.2.4
    
        
            get-the-git-infos
            
                revision
            
        
    
    
        ${project.basedir}/.git
        git
        false
        true
        ${project.build.outputDirectory}/git.properties
        json
        
            false
            false
            -dirty
        
    
    

    Add finalName to build section to also have the version in the target file name

    
    
    ${project.artifactId}-${project.version}-${git.commit.id.describe-short}
    
    ...
    
    
    

提交回复
热议问题