vect
vect

Reputation: 665

How does Maven resolve a version of a plugin to execute?

There are several downloaded versions of maven-dependency-plugin in my local repository. In a metadata file placed in org/apache/maven/plugins/maven-dependency-plugin/ versions from 2.0-alpha-1 to 2.10 are listed.
Version 2.10 is set as release and latest.

Despite that when dependency:get is executed as a standalone goal from CLI Maven uses the version 2.1. This is the lesser downloaded version of the plugin. Moreover if the version is removed from the local repository Maven downloads it again.

Maven 3.0.4 is used.

Question: How does Maven determine which version of a plugin will be used when it's not specified explicitly?

Upvotes: 2

Views: 136

Answers (1)

A_Di-Matteo
A_Di-Matteo

Reputation: 27812

When executing a plugin' goal from command line without explicitely providing its version, Maven will use its latest one, except for plugins declared as part of the super pom, that is, the implic parent pom of all Maven builds.

In this case, the maven-dependency-plugin is part of the little (and decreasing) set of plugins declared in the parent pom, for which version 2.1 is specified till Maven version 3.0.5, from that version on then it has been updated to version 2.8.

Additionally, Maven resolves plugin versions via the default lifecycle bindings, depending on the packaging option declared in a pom.xml file (not applicable for command line executions though).

Upvotes: 1

Related Questions