(重新表述问题以更好地理解)为了详细说明我的问题不够详细,这些是我遇到的以下情况:项目:A 和 B。A 的根 pom 是项目 B 的父级。
由于我们发布过程的一些限制(这是为了提供一些当前的上下文,但这不应被视为绕过手头问题的主要驱动力),我需要更改两个项目的版本。
如果我更改 A 的版本,然后更改 B 的版本,则会收到以下错误消息:
mvn versions:update-parent -DallowSnapshots -DgenerateBackupPoms=false -DparentVersion="6.4.1-SNAPSHOT"
[WARNING] Not updating version: could not resolve any versions
Run Code Online (Sandbox Code Playgroud)
如果我更改 A 的版本,请调用mvn clean installA(我可以接受,尽管我希望能够在脚本中一次更改所有项目的版本和父项,而无需中间的、可能失败的构建) ,则 B 上的上述命令有效,但前提是指定的父版本是最新可用的。否则我得到:
[INFO] Current version of parentGroup:parentArtifact:pom:7.0.12 is the latest.
Run Code Online (Sandbox Code Playgroud)
这意味着我不能使用该mvn versions:update-parent命令来更改维护分支上的父版本。
有没有办法mvn versions:update-parent尊重所需的父版本?(无论是否可以在本地、nexus 存储库中找到或根本找不到)
编辑:附加信息-X(删除了不相关的部分,强调我的)
[DEBUG] Configuring mojo 'org.codehaus.mojo:versions-maven-plugin:2.5:update-parent' with basic configurator -->
[DEBUG] (f) allowSnapshots = true
[DEBUG] (f) generateBackupPoms = false
(...)
[DEBUG] (f) parentVersion = 7.0.11
[DEBUG] Determining update check for artifact groupId:artifactIdProjectA (C:\Users\donckels\.m2\repository\.......\artifactIdProjectA\maven-metadata-....-repository.xml) from ....-repository (http://..../nexus/content/groups/public)
(....)
[DEBUG] Searching for ....-repository.maven-metadata-....-repository.xml.lastUpdated in resolution tracking file.
[DEBUG] Reading resolution-state from: C:\Users\donckels\.m2\repository\.....\artifactIdProjectA\resolver-status.properties
(....)
[DEBUG] Proposal is to update from 7.0.12 to 7.0.12
[INFO] Current version of groupId:artifactIdProjectA:pom:7.0.12 is the latest.
Run Code Online (Sandbox Code Playgroud)
即使我指定了 7.0.11,它最终还是:
[DEBUG] Proposal is to update from 7.0.12 to 7.0.12
Run Code Online (Sandbox Code Playgroud)
如果之前已经构建了父版本,则此语法(版本号周围带有方括号)允许强制使用不是最新的版本:
mvn versions:update-parent -DallowSnapshots -DgenerateBackupPoms=false -DparentVersion="[7.0.11]"
Run Code Online (Sandbox Code Playgroud)
但父母有Maven让更新之前建成。否则它将忽略指定的版本。