Java 在Eclipse中更新多模块项目版本的便捷方法
我在Eclipse中有一个Maven多模块项目 每次我想更新版本时,我都会转到Java 在Eclipse中更新多模块项目版本的便捷方法,java,eclipse,maven,multi-module,versions-maven-plugin,Java,Eclipse,Maven,Multi Module,Versions Maven Plugin,我在Eclipse中有一个Maven多模块项目 每次我想更新版本时,我都会转到runas->runconfigurations…,更改目标versions的参数newVersion:将设置为更高的数字,然后运行目标 还有更直接的吗 请注意,我不能使用CI友好版本,因为它们与Maven发布插件冲突。以下是一个脚本,用于检查Maven构建系统是否需要更新。通过运行此脚本,您将获得所有更新(但不会应用任何更新)。这使您可以根据需要更改全部、部分或全部 mvn versions:display-plug
runas->runconfigurations…
,更改目标versions的参数newVersion
:将
设置为更高的数字,然后运行目标
还有更直接的吗
请注意,我不能使用CI友好版本,因为它们与Maven发布插件冲突。以下是一个脚本,用于检查Maven构建系统是否需要更新。通过运行此脚本,您将获得所有更新(但不会应用任何更新)。这使您可以根据需要更改全部、部分或全部
mvn versions:display-plugin-updates
mvn versions:display-parent-updates
mvn versions:display-dependency-updates
我通常将此脚本保存在顶级检查版本.sh
或检查版本.cmd
(针对脚本语言进行调整)中
要使此脚本正常工作,在/project/build/plugins
中,您需要org.codehaus.mojo:versions maven plugin:2.7
或更高版本。我通常这样配置插件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
有了这些工具,我目前可以在我的一个项目上获得输出
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.edwbuck.parserhelp:pascal-adapter >----------------
[INFO] Building pascal-adapter 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.7:display-plugin-updates (default-cli) @ pascal-adapter ---
[INFO] artifact com.github.sevntu-checkstyle:dsm-maven-plugin: checking for updates from central
[INFO] artifact net.nicoulaj.maven.plugins:checksum-maven-plugin: checking for updates from central
[INFO]
[INFO] The following plugin updates are available:
[INFO] maven-project-info-reports-plugin .................... 2.6 -> 3.0.0
[INFO]
[INFO] All plugins have a version specified.
[INFO]
[INFO] Project inherits minimum Maven version as: 3.5.4
[INFO] Plugins require minimum Maven version of: 3.2.1
[INFO]
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.976 s
[INFO] Finished at: 2020-04-16T07:52:12-05:00
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.edwbuck.parserhelp:pascal-adapter >----------------
[INFO] Building pascal-adapter 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.7:display-parent-updates (default-cli) @ pascal-adapter ---
[INFO] Project does not have a parent.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.325 s
[INFO] Finished at: 2020-04-16T07:52:15-05:00
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.edwbuck.parserhelp:pascal-adapter >----------------
[INFO] Building pascal-adapter 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.7:display-dependency-updates (default-cli) @ pascal-adapter ---
[INFO] artifact com.edwbuck.parserhelp:pascal_client: checking for updates from central
[INFO] artifact org.junit.jupiter:junit-jupiter-engine: checking for updates from central
[INFO] artifact org.junit.jupiter:junit-jupiter-api: checking for updates from central
[INFO] artifact org.influxdb:influxdb-java: checking for updates from central
[INFO] The following dependencies in Dependencies have newer versions:
[INFO] org.junit.jupiter:junit-jupiter-api ................... 5.6.0 -> 5.6.2
[INFO] org.junit.jupiter:junit-jupiter-engine ................ 5.6.0 -> 5.6.2
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.848 s
[INFO] Finished at: 2020-04-16T07:52:18-05:00
[INFO] ------------------------------------------------------------------------
[INFO]正在扫描项目。。。
[信息]
[信息]-----------------------
[信息]正在构建pascal适配器1.0.0
[信息]------------------------------------[jar]---------------------------------
[信息]
[信息]---版本maven插件:2.7:显示插件更新(默认cli)@pascal适配器---
[信息]artifact com.github.sevntu checkstyle:dsm maven插件:检查来自central的更新
[INFO]artifact net.nicoolaj.maven.plugins:checksum maven plugin:checking for updates from central
[信息]
[信息]以下插件更新可用:
[信息]maven项目信息报告插件。。。。。。。。。。。。。。。。。。。。2.6 -> 3.0.0
[信息]
[信息]所有插件都指定了一个版本。
[信息]
[INFO]项目继承的最低Maven版本为:3.5.4
[信息]插件至少需要Maven版本:3.2.1
[信息]
[信息]没有插件需要比pom指定的版本更新的Maven。
[信息]
[信息]------------------------------------------------------------------------
[信息]建立成功
[信息]------------------------------------------------------------------------
[信息]总时间:2.976秒
[信息]完成时间:2020-04-16T07:52:12-05:00
[信息]------------------------------------------------------------------------
[信息]正在扫描项目。。。
[信息]
[信息]-----------------------
[信息]正在构建pascal适配器1.0.0
[信息]------------------------------------[jar]---------------------------------
[信息]
[信息]---版本maven插件:2.7:显示父级更新(默认cli)@pascal适配器---
[INFO]项目没有父项。
[信息]------------------------------------------------------------------------
[信息]建立成功
[信息]------------------------------------------------------------------------
[信息]总时间:1.325秒
[信息]完成时间:2020-04-16T07:52:15-05:00
[信息]------------------------------------------------------------------------
[信息]正在扫描项目。。。
[信息]
[信息]-----------------------
[信息]正在构建pascal适配器1.0.0
[信息]------------------------------------[jar]---------------------------------
[信息]
[信息]---版本maven插件:2.7:显示依赖项更新(默认cli)@pascal适配器---
[INFO]artifact com.edwbuck.parserhelp:pascal_客户端:检查来自central的更新
[信息]artifact org.junit.jupiter:junit-jupiter引擎:检查来自中心的更新
[信息]artifact org.junit.jupiter:junit-jupiter api:检查来自central的更新
[INFO]artifact org.influxdb:influxdb java:检查来自central的更新
[信息]依赖项中的以下依赖项具有较新版本:
[信息]org.junit.jupiter:junitjupiter api。。。。。。。。。。。。。。。。。。。5.6.0 -> 5.6.2
[信息]org.junit.jupiter:junitjupiter引擎。。。。。。。。。。。。。。。。5.6.0 -> 5.6.2
[信息]
[信息]------------------------------------------------------------------------
[信息]建立成功
[信息]------------------------------------------------------------------------
[信息]总时间:1.848秒
[信息]完成时间:2020-04-16T07:52:18-05:00
[信息]------------------------------------------------------------------------
这表明我需要更新我的maven项目信息报告插件
和我的org.junit.jupiter:junit-jupiter api
和org.junit.jupiter:junit-jupiter引擎
插件
通常我不会使用maven版本插件来实际更新pom.xml文件,因为如果您同时在pom.xml文件中执行所有更新,那么文本编辑器速度很快
目前,codehaus提供的maven版本插件没有一个命令行选项来一次自动更新多个版本。它不存在的原因很简单。要使用versions:updateproperties
插件,需要:
检查更新
脚本的输出时决定更新或不更新什么
这是因为自动更新插件和依赖项并不总是安全的。有时,插件的下一个版本需要对项目进行代码更改。例如,从Java8到Java9的项目需要改变它们的构建和链接方式。如果您想保持
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.edwbuck.parserhelp:pascal-adapter >----------------
[INFO] Building pascal-adapter 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.7:display-plugin-updates (default-cli) @ pascal-adapter ---
[INFO] artifact com.github.sevntu-checkstyle:dsm-maven-plugin: checking for updates from central
[INFO] artifact net.nicoulaj.maven.plugins:checksum-maven-plugin: checking for updates from central
[INFO]
[INFO] The following plugin updates are available:
[INFO] maven-project-info-reports-plugin .................... 2.6 -> 3.0.0
[INFO]
[INFO] All plugins have a version specified.
[INFO]
[INFO] Project inherits minimum Maven version as: 3.5.4
[INFO] Plugins require minimum Maven version of: 3.2.1
[INFO]
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.976 s
[INFO] Finished at: 2020-04-16T07:52:12-05:00
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.edwbuck.parserhelp:pascal-adapter >----------------
[INFO] Building pascal-adapter 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.7:display-parent-updates (default-cli) @ pascal-adapter ---
[INFO] Project does not have a parent.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.325 s
[INFO] Finished at: 2020-04-16T07:52:15-05:00
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.edwbuck.parserhelp:pascal-adapter >----------------
[INFO] Building pascal-adapter 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.7:display-dependency-updates (default-cli) @ pascal-adapter ---
[INFO] artifact com.edwbuck.parserhelp:pascal_client: checking for updates from central
[INFO] artifact org.junit.jupiter:junit-jupiter-engine: checking for updates from central
[INFO] artifact org.junit.jupiter:junit-jupiter-api: checking for updates from central
[INFO] artifact org.influxdb:influxdb-java: checking for updates from central
[INFO] The following dependencies in Dependencies have newer versions:
[INFO] org.junit.jupiter:junit-jupiter-api ................... 5.6.0 -> 5.6.2
[INFO] org.junit.jupiter:junit-jupiter-engine ................ 5.6.0 -> 5.6.2
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.848 s
[INFO] Finished at: 2020-04-16T07:52:18-05:00
[INFO] ------------------------------------------------------------------------