- <repositories>
(not actually available in the main POM, but used behind the scenes) - a subset of the
element, which consists of:
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里设置
- <settings>
- ...
- <profiles>
- <profile>
- <id>profile1id>
- ...
- profile>
- profiles>
- <activeProfiles>
- <activeProfile>profile-1activeProfile>
- activeProfiles>
- ...
- settings>
列在
3)Profiles还可以基于detect到的build environment 的state来自动激活,而不需要象上面2种方式显式激活。这只需要在profile定义时使用
- <profiles>
- <profile>
- <activation>
- <jdk>1.4jdk>
- activation>
- ...
- profile>
- profiles>
上面的代码表示:如果JDK version start with 1.4 (eg. "1.4.0_08", "1.4.2_07", "1.4"),该profile会被激活
- <profiles>
- <profile>
- <activation>
- <property>
- <name>debugname>
- property>
- activation>
- ...
- profile>
- profiles>
上面的代码表示:如果存在system propertie “debug”,该profile会被激活。为了激活它,输入的命令类似于:
- mvn groupId:artifactId:goal ?Ddebug
- <profiles>
- <profile>
- <activation>
- <property>
- <name>environmentname>
- <value>testvalue>
- property>
- activation>
- ...
- profile>
- profiles>
上面的代码表示:如果存在system propertie “environment”的值为test,该profile会被激活。为了激活它,输入的命令类似于:
- mvn groupId:artifactId:goal -Denvironment=test
4)Profiles还可以基于OS setting来自动激活