是否可以覆盖maven pluginManagement中的执行?

Mik*_*ike 9 maven

在父母POM中,我有:

 <pluginManagement>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                       <id>execution 1</id>
                       ...
                    </execution>
                    <execution>
                       <id>execution 2</id>
                       ...
                    </execution>
                    <execution>
                       <id>execution 3</id>
                       ...
                    </execution>
                </executions>
            </plugin>
        <pluginManagement>
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 是否可以<execution>在子项目中禁用某些项目,例如,仅运行execution 3并跳过1和2?
  2. 是否有可能完全覆盖子项目中的执行,例如我exection 4在子项目中有一个,我只想运行它,execution并且永远不会在父POM中运行执行1,2,3.

DB5*_*DB5 16

快速选项是<phase>none</phase>在覆盖每次执行时使用.因此,例如,只运行执行3,您将在您的pom中执行以下操作:

<build>
  <plugins>
    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <executions>
            <execution>
                <id>execution 1</id>
                <phase>none</phase>
                ...
            </execution>
            <execution>
                <id>execution 2</id>
                <phase>none</phase>
                ...
            </execution>
            <execution>
                <id>execution 3</id>
                ...
            </execution>
        </executions>
    </plugin>
    ...
  </plugins>
  ...
</build>
Run Code Online (Sandbox Code Playgroud)

应该注意的是,这不是官方记录的功能,因此可以随时删除对此的支持.

推荐的解决方案可能是定义profiles哪些activation部分已定义:

<profile>
  <id>execution3</id>
  <activation>
    <property>
      <name>maven.resources.plugin.execution3</name>
      <value>true</value>
    </property>
  </activation>
  ...
Run Code Online (Sandbox Code Playgroud)

在您的子项目中,您只需设置所需的属性:

<properties>
    <maven.resources.plugin.execution3>true</maven.resources.plugin.execution3>
</properties>
Run Code Online (Sandbox Code Playgroud)

有关配置文件激活的更多详细信息,请访问:http: //maven.apache.org/settings.html#Activation