我有两个 Maven 配置文件 profile-A 和 profile-B。仅当“A”未激活时才应激活“B”。
所以如果我打电话
mvn install
执行配置文件 B(但不执行配置文件 A)。
但如果我打电话
mvn install -Pprofile-A
则仅执行配置文件 A(但不执行配置文件 B)。
有什么提示我需要如何编写 pom.xml 来实现此目的吗?
我已经尝试过这个,但它不起作用:
<profiles>
<profile>
<id>profile-A</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
...
</profile>
<profile>
<id>profile-B</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!profile-A</name>
</property>
...
</activation>
...
</profile>
</profiles>
我认为为了让您的示例命令行按预期工作,您所需要的就是<activeByDefault>true</activeByDefault>
对于配置文件 B。
http://maven.apache.org/guides/introduction/introduction-to-profiles.html http://maven.apache.org/guides/introduction/introduction-to-profiles.html states:
当 POM 中的配置文件通过命令行或通过其激活配置激活时,默认情况下处于活动状态的所有配置文件都会自动停用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)