Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does importing maven dependencies impact plugin management?

Maven allows one to import dependencies, for example importing Spring Boot dependencies, into a project that has a different parent using import scope. How does this impact plugin management?

I want to use the plugin versions defined in the <pluginManagement> section of the imported dependency (<spring-boot-dependencies> in this case), but I notice different versions of plugins, like surefire, used in different environments, like on TeamCity and locally.

like image 592
Niel de Wet Avatar asked Nov 15 '16 09:11

Niel de Wet


People also ask

What is difference between Maven dependency and plugin?

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.

What is the use of Maven dependency plugin?

The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.

What is Maven plugin Management?

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.

What are the different dependencies we need to add in Maven?

There are two types of dependencies in Maven: direct and transitive. Direct dependencies are the ones that we explicitly include in the project. On the other hand, transitive dependencies are required by direct dependencies. Maven automatically includes required transitive dependencies in our project.


2 Answers

With maven you can only inherit pluginManagement when using that POM as a parent.
Scope import only brings you dependencyManagement.

There is a ticket on the maven issue tracker though : https://issues.apache.org/jira/browse/MNG-5588

like image 161
Michael Técourt Avatar answered Oct 04 '22 09:10

Michael Técourt


According to the Spring Boot docs, when Using Spring Boot without the parent POM, you can still keep the benefit of the dependency management (but not the plugin management).

like image 4
Niel de Wet Avatar answered Oct 04 '22 10:10

Niel de Wet