Is it possible to override executions in maven pluginManagement?

前端 未结 1 521
深忆病人
深忆病人 2020-12-17 18:25

In parent POM, I have:

 
            
                maven-resources-plugin
              


        
相关标签:
1条回答
  • 2020-12-17 18:27

    A quick option is to use <phase>none</phase> when overriding each execution. So for example to run execution 3 only you would do the following in your 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>
    

    It should be noted that this is not an officially documented feature, so support for this could be removed at any time.

    The recommend solution would probably be to define profiles which have activation sections defined:

    <profile>
      <id>execution3</id>
      <activation>
        <property>
          <name>maven.resources.plugin.execution3</name>
          <value>true</value>
        </property>
      </activation>
      ...
    

    The in your sub project you would just set the required properties:

    <properties>
        <maven.resources.plugin.execution3>true</maven.resources.plugin.execution3>
    </properties>
    

    More details on profile activation can be found here: http://maven.apache.org/settings.html#Activation

    0 讨论(0)
提交回复
热议问题