select maven profile based on git branch

三世轮回 提交于 2019-12-07 08:58:42

问题


Is it possible to select a profile based on what the current git branch is?

For example, if you are in the master branch, it selects the 'production' profile. If it is the develop branch, it selects the 'development' profile.

I found the mavanagaiata plugin which provides the mvngit.branch property but it can not be used in the <profiles> section.

Is something like this possible? Or are there better ways? I want an easy way to automatically select the correct profile depending on the branch being build.


回答1:


Make the profile activation by a file. Then create the file in a corresponding branch only, so that when you switch branches the file will appear or disappear, it will affect the profile activation.

However, I feel that it is bad idea to select maven profile based on git branch.




回答2:


  1. Use profile ID the same as your git branch.
  2. Run maven with corresponding profile:

    mvn clean deploy -P $(git rev-parse --abbrev-ref HEAD)



来源:https://stackoverflow.com/questions/12220517/select-maven-profile-based-on-git-branch

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