Injecting current git commit id into Java webapp

后端 未结 6 1190
抹茶落季
抹茶落季 2020-12-08 16:14

We have a git repository which contains source for a few related Java WARs and JARs. It would be nice if the Java code could somehow:

System.err.println(\"I          


        
6条回答
  •  萌比男神i
    2020-12-08 16:47

    If it helps for someone else. I know yours is ANT

    For MAVEN build, you could probably use git-commit-id-plugin in your pom.xml file

        
            pl.project13.maven
            git-commit-id-plugin
            2.2.0
            
                
                    
                        revision
                    
                
            
            
                ${project.basedir}/.git
                true
                ${project.build.outputDirectory}/git.properties
            
        
    

    Please go through :
    1. http://www.baeldung.com/spring-git-information &
    2. https://github.com/ktoso/maven-git-commit-id-plugin for more info.

提交回复
热议问题