Maven中的profiles应用(2)

激活Profiles

  激活profiles有下列几种方式:

Explicitly
Through Maven settings
Based on environment variables
OS settings
Present or missing files

  1)通过mvn命令的-P参数来显示激活profiles,该参数值是profile id list(之间用逗号连接)。如:

  mvn groupId:artifactId:goal -P profileId-1,profileId-2

  2)通过在settings.xml里设置<activeProfiles> element来激活(当然<profiles>也必须在settings.xml里定义)

<settings>
...
<profiles>
<profile>
  <id>profile1</id>
  ...
</profile>
</profiles>
  
<activeProfiles>
  <activeProfile>profile-1</activeProfile>
</activeProfiles>
...
</settings>

  列在<activeProfiles>里的profiles list会在每一个project执行时被激活

  3)Profiles还可以基于detect到的build environment 的state来自动激活,而不需要象上面2种方式显式激活。这只需要在profile定义时使用<activation> element。如:

<profiles>
<profile>
  <activation>
   <jdk>1.4</jdk>
  </activation>
  ...
</profile>
</profiles>

  上面的代码表示:如果JDK version start with 1.4 (eg. "1.4.0_08", "1.4.2_07", "1.4"),该profile会被激活

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值