maven exclude plugin defined in parent pom

22,907

Solution 1

You can declare all the plugins in your parent pom within <pluginManagement>. In each child, you can declare the plugins which are used by that child. This way, you can include or exclude plugins as appropriate.

You can look at this related SO discussion as well.

Solution 2

I had a similar requirement to run some plugins in the child but not the parent POM. i achieved this by stating <skip>true</skip> in the parent POM.

the parent pom entry is below

<plugin>
        <groupId>eviware</groupId>
        <artifactId>maven-soapui-plugin</artifactId>
        <version>4.0.0</version>
        <inherited>false</inherited>
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
          </dependency>
        </dependencies> 
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin> 

The child project pom entry is below

<plugins>
        <plugin>
            <groupId>eviware</groupId>
            <artifactId>maven-soapui-plugin</artifactId>
            <version>4.0.0</version>
            <configuration>
                <settingsFile>site-service-web/src/test/soapui/soapui-settings.xml</settingsFile>
                <projectFile>site-service-web/src/test/soapui/PodifiSite-soapui-project.xml</projectFile>
                <outputFolder>site-service-web/target/surefire-reports</outputFolder>
                <junitReport>true</junitReport>
                <exportwAll>true</exportwAll>
                <printReport>true</printReport>
            </configuration>
        </plugin>
    </plugins>

Solution 3

You can define all plugins in parent pom in pluginManagement section

    <pluginManagement>
            <plugins>
                ...
                 <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.8</version>
                    <executions>
                        <execution>
                            <id>unpack-dependencies</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>unpack-dependencies</goal>
                            </goals>
                            <configuration>
                                <includeTypes>tar.bz2</includeTypes>
                                <outputDirectory>${project.basedir}/target/dependencies</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
              ...
            </plugins>
</pluginManagement>

And after in parent and child poms you can control the execution phase of this plugin

<plugins>
      <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>
                    <phase>none</phase>
                </execution>
            </executions>
        </plugin>
  </plugins>

If you paste this in parent pom do not forget option <inherited>false</inherited>, its disable execution inheritance in child pom.

Solution 4

You could use a profile activated by a property to determine whether the plugin is used or not. By default the property could be activated and the one project you do not want to use it in could include the property value to exclude the plugin.

Share:
22,907

Related videos on Youtube

user373201
Author by

user373201

Updated on July 09, 2022

Comments

  • user373201
    user373201 6 months

    I have a parent pom with a few plugins. In my child pom, I want to exclude one plugin.

    How can I do this?

  • user373201
    user373201 almost 12 years
    In my case I have a plugin that is used by 9 out of 10 sub modules. I thought it would be easier to put the plugin in parent and let the 9 children inherit and tell the 10th one to exclude. I know the way you are talking about. Just wondering if its possible to just exclude a plugin from a child project....If maven doesn't have that ability, that is fine. I don't know maven all together, so posted here to find out if maven has that sort of a feature.
  • Pablo Lalloni
    Pablo Lalloni almost 9 years
    This answer does not really answer the question of how to exclude some particular inherited plugin.
  • ctron
    ctron over 5 years
    This works like a charm and even has the advantage that the plugin is never executed in the first place. Using ignore will actually still call into the plugin, but let the plugin decide. Using phase=none prevent Maven from even lookup up the plugin's classpath, which can be helpful in some scenarios.
  • Jeremy Moritz
    Jeremy Moritz almost 4 years
    the <configuration><skip>true</skip></configuration> also works when you put it in the child pom