Jus*_*tin 12 maven-plugin maven-3 maven
我正在阅读文档,但仍然对Maven如何决定下载哪个版本的插件感到困惑.
例如,考虑这个简单的场景:
mvn archetype:generate
对于Maven in 5 Minutes doc中maven-archetype-quickstart
所描述的.运行命令后,Maven所做的第一件事就是下载一堆插件.
Maven正在下载的一些插件包括:
为什么那些版本?
这些插件的最新版本是:
我查看了maven-clean-plugin 的最新版本元数据,它是2.5
并不是说我一定想强迫Maven使用这些插件的不同版本,我只想了解为什么它会解决这些版本.
我正在使用Apache Maven 3.0.3
Ash*_*wal 10
Maven在META-INF/plexus/components.xml中定义了3个生命周期:
1.默认生命周期
在没有任何关联插件的情况下定义默认生命周期.这些生命周期的插件绑定是针对META-INF/plexus/default-bindings.xml中的每个包装单独定义的.
例如用于jar包装的插件绑定
<phases>
<process-resources>
org.apache.maven.plugins:maven-resources-plugin:2.6:resources
</process-resources>
<compile>
org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
</compile>
<process-test-resources>
org.apache.maven.plugins:maven-resources-plugin:2.6:testResources
</process-test-resources>
<test-compile>
org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile
</test-compile>
<test>
org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
</test>
<package>
org.apache.maven.plugins:maven-jar-plugin:2.4:jar
</package>
<install>
org.apache.maven.plugins:maven-install-plugin:2.4:install
</install>
<deploy>
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
</deploy>
</phases>
Run Code Online (Sandbox Code Playgroud)
2. Clean Lifecycle clean生命周期直接使用其插件绑定定义.
<phases>
<phase>pre-clean</phase>
<phase>clean</phase>
<phase>post-clean</phase>
</phases>
<default-phases>
<clean>
org.apache.maven.plugins:maven-clean-plugin:2.5:clean
</clean>
</default-phases>
Run Code Online (Sandbox Code Playgroud)
3.站点生命周期 站点生命周期直接使用其插件绑定定义.
<phases>
<phase>pre-site</phase>
<phase>site</phase>
<phase>post-site</phase>
<phase>site-deploy</phase>
</phases>
<default-phases>
<site>
org.apache.maven.plugins:maven-site-plugin:3.3:site
</site>
<site-deploy>
org.apache.maven.plugins:maven-site-plugin:3.3:deploy
</site-deploy>
</default-phases>
Run Code Online (Sandbox Code Playgroud)
如果要覆盖这些默认插件版本,可以从命令提示符处执行,如下所示
mvn org.apache.maven.plugins:maven-clean-plugin:2.0:clean
Run Code Online (Sandbox Code Playgroud)
代替
mvn clean:clean
Run Code Online (Sandbox Code Playgroud)
每个版本的Maven二进制文件都有某些版本的插件版本硬编码.这是为了在用户不提供自己的版本信息的情况下进行一些可重现的构建.我们鼓励您这样做,一旦您<pluginManagement>
使用您选择的插件版本填充部分,构建将开始使用它.
归档时间: |
|
查看次数: |
5347 次 |
最近记录: |