我想重寫在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