set up maven pom file for different deployment scenarios

落爺英雄遲暮 提交于 2019-12-11 23:42:27

问题


Very new to maven. I have a pom file that I can use to do a build and deploy of my j2ee project and its working fine. (using maven 3).

I was wondering how to set up two different deployment scenario's in the same pom - one to build and deploy in my dev environment and one to build and deploy to a test environment.

The only differences between the two (for now) will be:

dev-build does NOT do an SCM checkout dev-build deploys to tomcat server A

test build does do an SCM checkout test build deploys to tomcat server B

What mechanisms in maven are best to use for creating two different deployment scenarios in this way. I've seen profiles mentioned - is this what I should be using - and if profiles is the answer how do I, for example, include an scm checkout for one profile but not for the other.

Thanks for any replies.


回答1:


This definitely sounds like a profile solution would work best. Each profile would have its specific build steps, plugins, properties, etc. The profile can define an activation section to determine when a profile is active. The activation can be base on several things like OS, JDK version, or environment variable. For explicit control, profiles can be toggled on and off using the -P command line option:

mvn -P profile1,!profile2 

That command activates profile1 and deactivates profile2.



来源:https://stackoverflow.com/questions/9088846/set-up-maven-pom-file-for-different-deployment-scenarios

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