Put current git branch to project version

大城市里の小女人 提交于 2020-01-01 08:53:31

问题


I want to put the current git branch into the version field in pom xml. I found some post in the internet suggesting to do something like:

<version>${scm.version}</version>

but this seems not to work with git. Are there any other solutions?


回答1:


Yes, use the git commit id plugin for maven

It's pretty straightforward. You can use it to get the git branch with

${git.branch}

So in your case it would go:

<version>${git.branch}</version>



回答2:


i created a plugin for this behavior (and by extend to link sonar to my maven projects).

The only thing you need to do is

add following plugin to your pom.xml

<plugin>
    <groupId>com.viae-it.maven</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
     <version>LATEST</version>
</plugin>

call the plugin to set the git branch

mvn com.viae-it.maven:sonar-maven-plugin:set-git-branch

then you can use the sonar.branch property



来源:https://stackoverflow.com/questions/21553304/put-current-git-branch-to-project-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!