maven如何快速更新子模組專案的版本號
需求描述
複雜的maven專案,通常包含多個子模組專案,如果手工逐個去修改每個pom.xml,會非常的耗時耗力,而且容易出錯和遺漏。
解決方案
藉助maven的versions外掛,可以比較容易的解決這個問題。方法如下:
mvn versions:set -DnewVersion=0.29-SNAPSHOT
versions外掛還提供了其它靈活的功能,可以通過"mvn versions:help"來檢視幫助資訊,根據選項的描述來實驗一下實際效果。
bj-m-211510a:target jinguang1$ mvn versions:help
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.5:help (default-cli) @ standalone-pom ---
[INFO] Versions Maven Plugin 2.5
Versions Plugin for Maven. The Versions Plugin updates the versions of
components in the POM.
This plugin has 31 goals:
versions:commit
Removes the initial backup of the pom, thereby accepting the changes.
versions:compare-dependencies
Compare dependency versions of the current project to dependencies or
dependency management of a remote repository project. Can optionally update
locally the project instead of reporting the comparison
versions:dependency-updates-report
Generates a report of available updates for the dependencies of a project.
versions:display-dependency-updates
Displays all dependencies that have newer versions available. It will also
display dependencies which are used by a plugin or defined in the plugin
within a pluginManagement.
versions:display-parent-updates
Displays any updates of the project's parent project
versions:display-plugin-updates
Displays all plugins that have newer versions available.
versions:display-property-updates
Displays properties that are linked to artifact versions and have updates
available.
versions:force-releases
Replaces any -SNAPSHOT versions with a release version, older if necessary (if
there has been a release).
versions:help
Display help information on versions-maven-plugin.
Call mvn versions:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
versions:lock-snapshots
Attempts to resolve unlocked snapshot dependency versions to the locked
timestamp versions used in the build. For example, an unlocked snapshot
version like '1.0-SNAPSHOT' could be resolved to '1.0-20090128.202731-1'. If a
timestamped snapshot is not available, then the version will remained
unchanged. This would be the case if the dependency is only available in the
local repository and not in a remote snapshot repository.
versions:plugin-updates-report
Generates a report of available updates for the plugins of a project.
versions:property-updates-report
Generates a report of available updates for properties of a project which are
linked to the dependencies and/or plugins of a project.
versions:resolve-ranges
Attempts to resolve dependency version ranges to the specific version being
used in the build. For example a version range of '[1.0, 1.2)' would be
resolved to the specific version currently in use '1.1'.
versions:revert
Restores the pom from the initial backup.
versions:set
Sets the current project's version and based on that change propagates that
change onto any child modules as necessary.
versions:set-property
Set a property to a given version without any sanity checks. Please be careful
this can lead to changes which might not build anymore. The sanity checks are
done by other goals like update-properties or update-property etc. they are
not done here. So use this goal with care.
versions:set-scm-tag
Updates the current project's SCM tag.
versions:unlock-snapshots
Attempts to resolve unlocked snapshot dependency versions to the locked
timestamp versions used in the build. For example, an unlocked snapshot
version like '1.0-SNAPSHOT' could be resolved to '1.0-20090128.202731-1'. If a
timestamped snapshot is not available, then the version will remained
unchanged. This would be the case if the dependency is only available in the
local repository and not in a remote snapshot repository.
versions:update-child-modules
Scans the current projects child modules, updating the versions of any which
use the current project to the version of the current project.
versions:update-parent
Sets the parent version to the latest parent version.
versions:update-properties
Sets properties to the latest versions of specific artifacts.
versions:update-property
Sets a property to the latest version in a given range of associated
artifacts.
versions:use-dep-version
versions:use-latest-releases
Replaces any release versions with the latest release version.
versions:use-latest-snapshots
Replaces any release versions with the latest snapshot version (if it has been
deployed).
versions:use-latest-versions
Replaces any version with the latest version.
versions:use-next-releases
Replaces any release versions with the next release version (if it has been
released).
versions:use-next-snapshots
Replaces any release versions with the next snapshot version (if it has been
deployed).
versions:use-next-versions
Replaces any version with the latest version.
versions:use-reactor
Replaces any versions with the corresponding version from the reactor.
versions:use-releases
Replaces any -SNAPSHOT versions with the corresponding release version (if it
has been released).
相關文章
- SpringBoot + maven 父子模組專案搭建Spring BootMaven
- 手把手教你把 Git 子模組更新到主專案Git
- 如何建立一個Maven專案(eclipse版本)MavenEclipse
- 如何在大型專案中使用Git子模組開發Git
- gitlab webhook 如何針對一個專案下的子模組配置GitlabWebHook
- 一行命令同時修改maven專案中多個mudule的版本號Maven
- Maven中如何管理多模組專案的依賴關係Maven
- 【版本2020.03】使用idea匯入maven專案IdeaMaven
- Maven如何只打包專案某個模組及其依賴模組?Maven
- Springboot建立maven多模組專案Spring BootMaven
- 如何在eclipse中的maven中永久修改jdk的版本號EclipseMavenJDK
- Maven依賴版本更新踩坑Maven
- Maven依賴版本號引發的血案Maven
- SpringBoot載入子模組配置檔案的方法Spring Boot
- Git 子模組Git
- 將maven專案劃分為多個模組Maven
- 為什麼在SpringBoot+maven的專案中,所引入的依賴包可以不指定依賴的版本號?Spring BootMaven
- Maven 專案文件Maven
- Maven 專案模板Maven
- 使用命令列建立Maven的專案或模組目錄命令列Maven
- Maven 高階篇之構建多模組專案的方法Maven
- 解決專案版本衝突——maven-shade外掛使用Maven
- eclipse中基於maven構建多模組專案EclipseMaven
- Spring Boot + Maven 多模組專案開發詳解Spring BootMaven
- Maven教程(Eclipse配置及maven專案)MavenEclipse
- 【PE】利用SVN的SubWCRev.exe管理同步專案的版本號
- maven 專案的建立入門Maven
- Java 使用 Maven BOM 統一管理版本號JavaMaven
- 新人如何快速上手新專案?
- 如何建立+管理maven、匯入web專案、xmlMavenWebXML
- 聊聊Git subModule(子模組)Git
- maven 多模組專案的測試覆蓋率分析 - jacoco 聚合分析Maven
- maven工程指定版本號並開啟預覽特性Maven
- Maven快速入門(四)Maven中的pom.xml檔案詳解MavenXML
- 如何更新composer包的git版本Git
- 如何快速上手React、Vue前端專案ReactVue前端
- maven 專案轉化成 gradle 專案實踐MavenGradle
- Node 快速切換版本、版本回退(降級)、版本更新(升級)