I am starting to use BOMs for centralizing the versions of common dependencies in my project. However, it does not seem to work for plugin versions: If I add a pluginManagement section in the BOM, the versions of the plugins declared there do not seem to affect the versions of the plugins of projects importing the BOM (Maven complains that the version has not been specified).
Why is that? What is then the "Maven" way to centralize the versions of common plugins? Should I just use a parent POM for that?
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.
Maven's dependency management includes the concept of a bill-of-materials (bom). A bom is a special kind of pom that is used to control the versions of a project's dependencies and provides a central place to define and update those versions.
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).
If you use a BOM which is used by scope import
which means only to take into account the dependencyManagement part. Excerpt from the docs:
This scope is only used on a dependency of type pom in the section. It indicates that the specified POM should be replaced with the dependencies in that POM's section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.
To define plugins you should use a parent where you define the plugin versions via pluginManagement.
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