问题描述
我想知道我什么时候没有在某些模块的 pom.xml 中指定插件版本,例如:
I wonder when I did not specify a plugin version in some module's pom.xml like in:
<build>
...
<plugin>
<groudId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
...
</build>
运行mvn compile"时使用的默认插件版本是什么?
What is the default plugin version used when I run "mvn compile"?
我已经试过了,实际上它使用的是 maven-compiler-plugin 版本3.1",上面的插件元素被注释,我的 maven 版本是 3.6.3.
I have tried it and see actually it is using maven-compiler-plugin version "3.1" with above plugin element commented, my maven version is 3.6.3.
我花了 1 小时通过 Maven 的文档和相关帖子在谷歌上搜索,但没有找到确切的答案.我真的很想知道那个版本是如何决定的?如果有人知道任何线索,不胜感激.
I have spent 1 hour to google thru Maven's documentation and related posts, but not find exact answer. I really like to know how that version is being decided? If anyone know any clue, it is greatly appreciated.
推荐答案
神奇的不是发生在超级 pom 中,而是发生在所谓的 bindings descriptor
中,可在 https://github.com/apache/maven/blob/master/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml.但是,他们正在转向匹配的打包插件,例如 maven-jar-plugin 它位于 https://github.com/apache/maven-jar-plugin/blob/master/src/main/filtered-资源/META-INF/plexus/components.xml这些版本尚未更新,因为如果 2 个具有不同 Maven 版本的用户具有不同的结果(例如,一个构建损坏,另一个没有),那将会很奇怪.因此最好在 pom 中指定插件版本,不要依赖 Maven 提供的默认值.
The magic is not happening in the super pom, but in the so called bindings descriptor
as available at https://github.com/apache/maven/blob/master/maven-core/src/main/resources/META-INF/plexus/default-bindings.xml.However, they are moving to the matching packaging plugin, for example for the maven-jar-plugin it is located at https://github.com/apache/maven-jar-plugin/blob/master/src/main/filtered-resources/META-INF/plexus/components.xmlThese versions haven't been updated, because it would be weird if 2 users with different Maven versions have different results (e.g. one has a broken build, the other not). Hence it is better to specify the plugin versions in the pom, don't rely of the defaults provided by Maven.
最后在https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
这篇关于默认的 maven 插件版本是如何决定的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!