Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is pluginManagement in Maven's pom.xml?

This is a snippet of my pom file.

....         <plugins>             <plugin>                 <groupId>org.apache.maven.plugins</groupId>                 <artifactId>maven-dependency-plugin</artifactId>                 <version>2.4</version>                                         <executions>                     <execution>                         <phase>install</phase>                         <goals>                             <goal>copy-dependencies</goal>                         </goals>                         <configuration>                             ......                         </configuration>                     </execution>                 </executions>             </plugin>         </plugins> ... 

I use it successfully with the command

mvn install 

But, when I try to enclose it into the "pluginManagement" tag, the maven-dependency-plugin stops working when I launch the install goal. Why does the "pluginManagement" tag change the build behavior? Or should I use another goal or option?

like image 466
Andrea Borgogelli Avveduti Avatar asked May 07 '12 13:05

Andrea Borgogelli Avveduti


People also ask

What is plugin in Maven POM XML?

Plugins are the central feature of Maven that allow for the reuse of common build logic across multiple projects. They do this by executing an "action" (i.e. creating a WAR file or compiling unit tests) in the context of a project's description - the Project Object Model (POM).

Where do plugins go in POM XML?

Build plugins They execute during the build process and should be configured in the <build/> element of pom. xml.

What is the difference between plugin and dependency?

A plugin is an extension to Maven, something used to produce your artifact (maven-jar-plugin for an example, is used to, you guess it, make a jar out of your compiled classes and resources). A dependency is a library that is needed by the application you are building, at compile and/or test and/or runtime time.


1 Answers

You still need to add

<plugins>     <plugin>         <groupId>org.apache.maven.plugins</groupId>         <artifactId>maven-dependency-plugin</artifactId>     </plugin> </plugins> 

in your build, because pluginManagement is only a way to share the same plugin configuration across all your project modules.

From Maven documentation:

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. However, this only configures plugins that are actually referenced within the plugins element in the children. The children have every right to override pluginManagement definitions.

like image 126
jordeu Avatar answered Sep 18 '22 12:09

jordeu