Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven exclude plugin defined in parent pom

Tags:

maven

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

How can I do this?

like image 634
user373201 Avatar asked Jan 29 '11 21:01

user373201


People also ask

Are plugins inherited from parent pom?

Plugins declared outside of <pluginManagement> are inherited by child POMs, by default. Their settings can be overridden by each child if desired.

What is the value required to discontinue the propagation of plugins to child POMs?

You can put the clean plugin inside the execution tag in pom. xml file. How to stop the propagation of plugins to child POMs? set <inherited> to false.

What is the difference between plugin and pluginManagement tags?

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.


2 Answers

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> 
like image 120
Rafeeq Avatar answered Nov 13 '22 07:11

Rafeeq


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.

like image 42
Doroshenko Avatar answered Nov 13 '22 05:11

Doroshenko