Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centralizing plugin version in (something similar to) a BOM?

Tags:

maven

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?

like image 774
Sergio Avatar asked Sep 09 '15 09:09

Sergio


People also ask

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.

What is Maven bom?

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.

What is the use of plugin in 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).


1 Answers

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.

like image 176
khmarbaise Avatar answered Sep 18 '22 09:09

khmarbaise