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.
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.
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.
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.
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.
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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With