【发布时间】:2018-07-03 15:21:36
【问题描述】:
我有一个父/根 POM,它 (1) 聚合子模块,以及 (2) 声明一个基于属性值有条件地激活的配置文件。所以:
<packaging>pom</packaging>
<modules>
<module>moduleA</module>
<module>moduleB</module>
<module>moduleC</module>
</modules>
<profiles>
<profile>
<id>myProfile</id>
<activation>
<property>
<name>animal</name>
<value>cat</value>
</property>
</activation>
</profile>
</profiles>
在moduleA 中,我声明了与父级相同的配置文件,并希望在我使用父级(animal == cat)的激活标准构建moduleA 时激活它。但这行不通。所以如果这是moduleA的POM:
<properties>
<shape>circle</shape>
</properties>
<profiles>
<profile>
<id>myProfile</id>
<properties>
<shape>square</shape>
</properties>
</profile>
</profiles>
我使用mvn help:evaluate -Danimal=cat 构建moduleA,评估${shape} 说它的值是circle,而不是我期望的square。因此,在使用其父级的激活标准构建时,子级配置文件似乎没有激活。
有没有办法做到这一点?我真的必须将 <activation> 块从父模块复制并粘贴到它的所有子模块中,才能获得相同的行为吗?
【问题讨论】:
标签: java maven maven-3 pom.xml parent-pom