Home > Net >  Why is the default version for the maven-compiler-plugin 3.1, a version from 2013, when the newest o
Why is the default version for the maven-compiler-plugin 3.1, a version from 2013, when the newest o

Time:10-03

As the title says. I figured this out recently when I wanted to use the release flag in my POM configuration. Why does Maven use such an old version?

I should add I'm using the latest Maven version (3.8.6).

CodePudding user response:

Why does Maven use such an old version?

In a word: Reproducibility.

Changing a plugin version number can result in changes in behavior that affect a Maven build. Now if the developer changes an explicit plugin version in their POM file, it is reasonable to assume that they made a conscious decision to do this. Either way, the decision to change was theirs.

On the other hand, when people rely on default plugin version numbers, they are not going to expect that they vary depending on the precise version of Maven that is installed. They won't be happy if the build instructions for some old projects require them to install an out-of-date version of Maven. And they won't be happy if installing a new Maven version to (say) patch a security problem also changes default plugin versions and ... unexpectedly breaks their builds.

Hence, the Maven team is extremely cautious about changing default plugin versions, and default properties.


Either way, the solution is in your own hands. If you want to use a more recent version of any plugin, just put an explicit plugin version in your project's parent POM file.

CodePudding user response:

Each Maven versions can contains different versions of core plugins.

When you don't lock used plugins version in your project, build can use different version of plugins when you change used Maven version.

It cause that your project build can be unreproducible with different Maven version.

So recommended way is lock all plugin version in project, you should create pluginManagement with all plugin version in your project on in your parent pom.

Even more Maven 4 will produce warning is such case: https://issues.apache.org/jira/browse/MNG-6562

  • Related