Maven:版本:update-parent,然后是install installs旧版本

时间:2017-09-05 08:08:36

标签: java maven build multi-module versions-maven-plugin

我有以下两个maven项目

pom.xml (parent)

-

pom.xml (aggregate, extends parent)
|
|--pom.xml (module, extends aggregate)

仅定义工件版本的位置是父级。其他项目或其模块直接或间接从父级继承该版本。我想自动将聚合版本及其模块版本与父版本匹配。

我升级了父版本和mvn install之后,我正在尝试使用 versions-maven-plugin 来升级聚合项目,并将其模块设置为与新父级匹配命令:

mvn versions:update-parent versions:update-child-modules clean install

正确升级父级和模块父级,但安装目标仍会在版本-maven-plugin 所做的更改之前安装该版本。如果我想安装升级版本,我必须在mvn clean install插件后单独调用versions。为什么install不在同一命令中选择versions插件所做的更改?我还尝试包含versions:commit但没有效果。这是构建日志以显示正在发生的事情。

tutoivon@IT-L-R90HKRNH MINGW64 ~/Desktop/mavenversiontest/aggregate (master)
$ mvn versions:update-parent versions:update-child-modules clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] aggregate
[INFO] module
[INFO] submodule
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aggregate 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.4:update-parent (default-cli) @ aggregate ---
[INFO] Updating parent from 1.0.0 to 2.0.0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building module 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.4:update-parent (default-cli) @ module ---
[INFO] Project's parent is part of the reactor
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building submodule 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.4:update-parent (default-cli) @ submodule ---
[INFO] Project's parent is part of the reactor
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aggregate 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.4:update-child-modules (default-cli) @ aggregate ---
[INFO] Module: module
[INFO]     parent was fi.tuomas.testi:aggregate:1.0.0
[INFO]     updated to fi.tuomas.testi:aggregate:2.0.0
[INFO] Module: module/submodule
[INFO]     parent was fi.tuomas.testi:module:1.0.0
[INFO]     updated to fi.tuomas.testi:module:2.0.0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aggregate 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ aggregate ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ aggregate ---
[INFO] Installing C:\Users\tutoivon\Desktop\mavenversiontest\aggregate\pom.xml to C:\Users\tutoivon\.m2\repository\fi\tuomas\testi\aggregate\1.0.0\aggregate-1.0.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building module 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ module ---
[INFO] Installing C:\Users\tutoivon\Desktop\mavenversiontest\aggregate\module\pom.xml to C:\Users\tutoivon\.m2\repository\fi\tuomas\testi\module\1.0.0\module-1.0.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building submodule 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ submodule ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ submodule ---
[INFO] Installing C:\Users\tutoivon\Desktop\mavenversiontest\aggregate\module\submodule\pom.xml to C:\Users\tutoivon\.m2\repository\fi\tuomas\testi\submodule\1.0.0\submodule-1.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] aggregate .......................................... SUCCESS [  0.125 s]
[INFO] module ............................................. SUCCESS [  0.010 s]
[INFO] submodule .......................................... SUCCESS [  0.011 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.626 s
[INFO] Finished at: 2017-09-05T11:03:49+03:00
[INFO] Final Memory: 15M/303M
[INFO] ------------------------------------------------------------------------

tutoivon@IT-L-R90HKRNH MINGW64 ~/Desktop/mavenversiontest/aggregate (master)
$ mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] aggregate
[INFO] module
[INFO] submodule
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aggregate 2.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ aggregate ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ aggregate ---
[INFO] Installing C:\Users\tutoivon\Desktop\mavenversiontest\aggregate\pom.xml to C:\Users\tutoivon\.m2\repository\fi\tuomas\testi\aggregate\2.0.0\aggregate-2.0.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building module 2.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ module ---
[INFO] Installing C:\Users\tutoivon\Desktop\mavenversiontest\aggregate\module\pom.xml to C:\Users\tutoivon\.m2\repository\fi\tuomas\testi\module\2.0.0\module-2.0.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building submodule 2.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ submodule ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ submodule ---
[INFO] Installing C:\Users\tutoivon\Desktop\mavenversiontest\aggregate\module\submodule\pom.xml to C:\Users\tutoivon\.m2\repository\fi\tuomas\testi\submodule\2.0.0\submodule-2.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] aggregate .......................................... SUCCESS [  0.333 s]
[INFO] module ............................................. SUCCESS [  0.012 s]
[INFO] submodule .......................................... SUCCESS [  0.012 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.448 s
[INFO] Finished at: 2017-09-05T11:04:10+03:00
[INFO] Final Memory: 7M/240M
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:0)

Maven在之后运行版本插件它已经解析了所有依赖版本,因此无法再调用它两次。一旦更新版本,然后构建项目。

maven执行阶段在this SO answer中得到了很好的解释。特别参见第7步。