我想重写在pom.xml中定义的特定插件配置。我不想因各种原因修改pom.xml。有没有一种方法可以在settings.xml中定义该插件的config属性来覆盖相应的pom.xml插件配置?在maven中,如何覆盖settings.xml中的插件配置
在下面的示例中,您会注意到插件xx-plugin
在pom.xml中的profile1
中定义。在我的settings.xml中,我已经定义了profile2
来覆盖来自pom.xml的属性prop1
。但如何覆盖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>
这是我的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>
建议:切勿在settings.xml中执行此类操作。此外,根据我在您的pom片段中看到的内容,这对我来说看起来是错误的...您为哪个插件配置了它们? – khmarbaise
该插件是公司专有的 - 它接收一组XML并生成Java类。你能详细解释一下吗,POM有什么问题? AFAIK它可以工作,除了更改的名称。我同意你的建议,不要在settings.xml中配置插件。但我的情况是 - 插件配置中有一个属性,我只想为我的环境重写。如果我更改了pom.xml,我可能会意外检入,或者每次切换分支时都可能会覆盖它。 – IdleCashew