Idl*_*hew 7 maven-plugin maven-3 maven
我想覆盖在 pom.xml 中定义的特定插件配置。出于各种原因,我不想修改 pom.xml。有没有办法在 settings.xml 中为该插件定义一个配置属性来覆盖相应的 pom.xml 插件配置?
在下面的例子中,你会注意到插件xx-plugin
是profile1
在 pom.xml 中定义的。在我的 settings.xml 中,我已经定义profile2
为覆盖prop1
pom.xml 中的属性。但是如何覆盖config3
. 如果这是一个愚蠢的问题,我深表歉意。我对 maven 有点陌生。
这是我的 pom.xml 的样子:
<profile>
<id>profile1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.xx.yyy</groupId>
<artifactId>xx-plugin</artifactId>
<executions>
<execution>
<id>xx-install</id>
<phase>install</phase>
<goals>
<goal>xx-install</goal>
</goals>
<configuration>
<config1>AAA</config1>
<config2>BBB</config2>
<config3>CCC</config3> <!-- I want to override this with value DDD -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
这是我的 settings.xml 的样子:
<profile>
<id>profile2</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<prop1>overriden-value</prop1> <!-- This works -->
</properties>
<!-- Somehow override config3 here -->
<!-- <config3>DDD</config3> -->
</profile>
Run Code Online (Sandbox Code Playgroud)
AFAIK 你只能用settings.xml
配置文件覆盖属性。您必须更改插件的配置才能使用属性而不是固定值:
<!-- define your property -->
<properties>
<prop1>CCC</prop1>
</properties>
<profile>
<id>profile1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.xx.yyy</groupId>
<artifactId>xx-plugin</artifactId>
<executions>
<execution>
<id>xx-install</id>
<phase>install</phase>
<goals>
<goal>xx-install</goal>
</goals>
<configuration>
<config1>AAA</config1>
<config2>BBB</config2>
<config3>${prop1}</config3> <!-- I want to override this with value DDD -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
请记住,如果在构建调用中激活任何其他配置文件,activeByDefault
则true
设置为 的配置文件将被停用。请参阅http://maven.apache.org/guides/introduction/introduction-to-profiles.html
归档时间: |
|
查看次数: |
2818 次 |
最近记录: |