激活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会被激活