muts
muts

Reputation: 21

maven 3: must specify plugin version, why?

Since maven 3 it is strongly recommended to specify the version of a plugin. For example, specifying the maven-compiler-plugin (in order to specify the java target version), maven complains if the version is not specified:

[WARNING] Some problems were encountered while building the effective model for com.example:ex1:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 20, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

I can understand the logic of this, however:

if I do not specify the maven-compiler-plugin, I will get a default version, being 2.3.2 for maven 3.0.4. This means that in the normal case, you will get some default version for a plugin.

The question: can the default version of a plugin vary over time? I guess so, e.g. maven 4.x might use a newer default version of the compiler plugin.

If this is the case, then what is the advantage of forcing users to specify the version? In many cases, it will be unpredictable anyways, looking only at the pom.xml, to know in advance what maven version will be used, i.e. also what maven plugin version will be used.

I don't get the logic behind this. Consequently, one should always be forced to specify the version of every plugin in use (which would be quite cumbersome).

Upvotes: 2

Views: 408

Answers (1)

bmargulies
bmargulies

Reputation: 100003

The default versions of plugins are part of the release package for Maven. So, they differ from release to release. Which implies that switching versions of Maven may get you a nasty surprise. The Maven dev community decided that this was a bad plan; that you should be able to change minor versions of Maven without losing build repeatability (except for bugs, of course). So, we put in this warning, to gently encourage you to lock down your plugin versions.

Upvotes: 2

Related Questions