set up maven pom file for different deployment sce

2019-08-18 01:35发布

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条回答
戒情不戒烟
2楼-- · 2019-08-18 02:02

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.

查看更多
登录 后发表回答