【发布时间】:2014-10-29 06:17:00
【问题描述】:
问题与Maven: Only activate profile A if profile B is not activated?有关,但更具体。
如果我输入以下内容之一:
mvn clean install -PspecificProfile
mvn clean install -Dsmth -PspecificProfile
mvn clean install -Dsmth -PspecificProfile,anotherProfile
然后我想激活specificProfile 个人资料。 (+额外指定的配置文件)
如果我输入其他类似的内容:
mvn install
mvn clean install
mvn clean install -Dsmth
mvn clean install -Dsmth -PanotherProfile
mvn clean install -Dsmth -PdefaultProfile
mvn clean install -Dsmth -PdefaultProfile,anotherProfile
然后我想激活defaultProfile(+其他指定的配置文件)。
想法:
if ( specific profile P is used via command line ) {
activate P;
} else {
activate the default profile;
}
activate other specified profiles;
示例:
mvn ... // default
mvn ... -PspecificProfile // specificProfile (no default!)
mvn ... -Px // default + x
mvn ... -Px,y // default + x + y
mvn ... -Px,specificProfile // x + specificProfile (no default!)
mvn ... -Px,specificProfile,y // x + specificProfile + y (no default!)
我试图做这样的事情(在 pom.xml 中):
<profile>
<id>defaultProfile</id>
<activation>
<property>!x</property>
</activation>
...
</profile>
<profile>
<id>specificProfile</id>
<properties>
<x>true</x>
</properties>
...
</profile>
但它不起作用。
【问题讨论】:
标签: java maven build maven-3 maven-profiles