Disable a Maven plugin defined in a parent POM

MavenMaven 2

Maven Problem Overview


I am using a parent POM that defines a plugin that I do not want to be run in a child POM. How can I disable the plugin in the child pom completely?

Constraint: I cannot change the parent POM itself.

Maven Solutions


Solution 1 - Maven

The following works for me when disabling Findbugs in a child POM:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>ID_AS_IN_PARENT</id> <!-- id is necessary sometimes -->
            <phase>none</phase>
        </execution>
    </executions>
</plugin>

Note: the full definition of the Findbugs plugin is in our parent/super POM, so it'll inherit the version and so-on.

In Maven 3, you'll need to use:

 <configuration>
      <skip>true</skip>
 </configuration>

for the plugin.

Solution 2 - Maven

See if the plugin has a 'skip' configuration parameter. Nearly all do. if it does, just add it to a declaration in the child:

<plugin>
   <groupId>group</groupId>
   <artifactId>artifact</artifactId>
   <configuration>
     <skip>true</skip>
   </configuration>
</plugin>

If not, then use:

<plugin>    
<groupId>group</groupId>   
 <artifactId>artifact</artifactId>    
<executions>
     <execution>
       <id>TheNameOfTheRelevantExecution</id>
       <phase>none</phase>
     </execution>    
</executions>  
</plugin>

Solution 3 - Maven

The thread is old, but maybe someone is still interested. The shortest form I found is further improvement on the example from λlex and bmargulies. The execution tag will look like:

<execution>
    <id>TheNameOfTheRelevantExecution</id>
    <phase/>
</execution>

2 points I want to highlight:

  1. phase is set to nothing, which looks less hacky than 'none', though still a hack.
  2. id must be the same as execution you want to override. If you don't specify id for execution, Maven will do it implicitly (in a way not expected intuitively by you).

After posting found it is already in stackoverflow: https://stackoverflow.com/questions/7800647/in-a-maven-multi-module-project-how-can-i-disable-a-plugin-in-one-child

Solution 4 - Maven

I know this thread is really old but the solution from @Ivan Bondarenko helped me in my situation.

I had the following in my pom.xml.

<build>
	...
	<plugins>
		 <plugin>
                <groupId>com.consol.citrus</groupId>
                <artifactId>citrus-remote-maven-plugin</artifactId>
                <version>${citrus.version}</version>
                <executions>
                    <execution>
                        <id>generate-citrus-war</id>
                        <goals>
                            <goal>test-war</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
	</plugins>
</build>

What I wanted, was to disable the execution of generate-citrus-war for a specific profile and this was the solution:

<profile>
	<id>it</id>
	<build>
		<plugins>
			<plugin>
				<groupId>com.consol.citrus</groupId>
				<artifactId>citrus-remote-maven-plugin</artifactId>
				<version>${citrus.version}</version>
				<executions>
					<!-- disable generating the war for this profile -->
					<execution>
						<id>generate-citrus-war</id>
						<phase/>
					</execution>

					<!-- do something else -->
					<execution>
						...
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</profile>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontobiasbayerView Question on Stackoverflow
Solution 1 - MavenAlexView Answer on Stackoverflow
Solution 2 - MavenbmarguliesView Answer on Stackoverflow
Solution 3 - MavenIvan BondarenkoView Answer on Stackoverflow
Solution 4 - MavenLiviu IleaView Answer on Stackoverflow