小编Idl*_*hew的帖子

在maven中,如何覆盖settings.xml中的插件配置

我想覆盖在 pom.xml 中定义的特定插件配置。出于各种原因,我不想修改 pom.xml。有没有办法在 settings.xml 中为该插件定义一个配置属性来覆盖相应的 pom.xml 插件配置?

在下面的例子中,你会注意到插件xx-pluginprofile1在 pom.xml 中定义的。在我的 settings.xml 中,我已经定义profile2为覆盖prop1pom.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 …
Run Code Online (Sandbox Code Playgroud)

maven-plugin maven-3 maven

7
推荐指数
1
解决办法
2818
查看次数

标签 统计

maven ×1

maven-3 ×1

maven-plugin ×1