I have just noticed that plugin's version is optional in maven. I can still build my module without specifying it. Let's take an example with maven-bundle-plugin.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
....
</plugin>
I have written a simple pom.xml without a parent to try this out, so pluginManagement is not involved. I have also checked the super super pom-4.0.0.xml in maven-model-builder to confirm that maven-bundle-plugin isn't there. This plugin version is not specified anywhere.
How does maven determine which version to take?
If you check the
maven-metadata.xml
file that is in your remote repository (e.g. Nexus) alongside the plugin artifact, you'll see something like this:I think Maven may use the
<latest>
value to decide which plugin to download if the version is not specified.Maven 3.0.x gives warnings for missing plugin versions and says "future versions of Maven may refuse to build malformed POMs like these" or something like that. You should always specify the plugin versions so your build is reproducible. Otherwise you can end up with some really hard to find bugs.
From Maven 3.x Compatibility Notes:
There are few steps maven follows to resolve the plugin version. It is documented in
Resolving Plugin Versions
section of http://maven.apache.org/guides/introduction/introduction-to-plugin-registry.html