为不同的部署方案设置maven pom文件 [英] set up maven pom file for different deployment scenarios

查看:180
本文介绍了为不同的部署方案设置maven pom文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对maven来说很新。我有一个pom文件,我可以用它来构建和部署我的j2ee项目,它的工作正常。 (使用maven 3)。

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).

我想知道如何在同一个pom中设置两个不同的部署方案 - 一个用于在我的开发环境中构建和部署,另一个用于构建并部署到测试环境。

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不执行SCM checkout
dev-build部署到tomcat服务器A

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

测试构建 执行SCM结账
测试构建部署到tomcat服务器B

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

maven中的哪些机制最适合用于以这种方式创建两个不同的部署方案。我已经看过提到的个人资料 - 这就是我应该使用的 - 如果个人资料是答案,我应该如何为一个资料包括一个scm结账但不包括另一个。

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.

感谢您的回复。

推荐答案

这听起来像个人资料解决方案效果最好。每个配置文件都有其特定的构建步骤,插件,属性等。配置文件可以定义激活部分以确定配置文件何时处于活动状态。激活可以基于OS,JDK版本或环境变量等几个方面。对于显式控制,可以使用-P命令行选项打开和关闭配置文件:

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 

该命令激活profile1并停用profile2。

That command activates profile1 and deactivates profile2.

这篇关于为不同的部署方案设置maven pom文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆