disable a plugin which imported from parent pom in child modul

Case1: the parent pom is tagged with an id

parent pom.xml

<plugin>
    <groupId>org.codehaus.mojogroupId>
    <artifactId>exec-maven-pluginartifactId>
    <version>1.2.1version>
    <executions>
        <execution>
            <id>i-do-somethingid>
            <phase>initializephase>
            <goals>
                <goal>execgoal>
            goals>
            <configuration>
                ... lots of configuration
            configuration>
        execution>
    executions>
plugin>

child pom.xml

<plugin>
    <groupId>org.codehaus.mojogroupId>
    <artifactId>exec-maven-pluginartifactId>
    <version>1.2.1version>
    <executions>
        <execution>
            <id>i-do-somethingid>
            <phase/>
        execution>
    executions>
plugin>

Case2: the parent pom doesn’t tag the execution with and id

Solution1:

edit the parent pom.xml and add a id to execution, and then use the [Case1] solution

Solution2:

parent pom.xml

<plugin>
  <artifactId>maven-source-pluginartifactId>
  <version>2.1.2version>
  <executions>
    <execution>
      <phase>packagephase>
      <goals>
        <goal>jargoal>
      goals>
    execution>
  executions>
  <inherited>trueinherited>
plugin>

child pom.xml

<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-source-pluginartifactId>
    <executions>
        <execution>
            <phase>nonephase>
        execution>
    executions>
plugin>

check

run mvn help:effective-pom to confirm that it has correctly suppressed what you needed suppressed from the parent pom.

参考文档

In a Maven multi-module project, how can I disable a plugin in one child?

你可能感兴趣的:(maven,plugin,java)