Maven 版本插件不更新反应堆的版本

maven versions plugin does not update versions for reactor

我目前正在尝试通过 maven 的版本插件更新内部库的依赖项。该插件巧妙地更新了外部库,但没有改变多模块库。

描述一下我之前做的事情

我之前构建过它们,所以文件与新版本一起存在。

在每个子模块上,我使用 versions:set 设置一个新版本(我遍历不同的子模块,因为父项目中每个库的主要和次要版本可能不同)并成功构建它们链接旧版本。

现在我想使用版本插件在所有依赖项中设置新版本,然后重建。

当我执行时:

mvn -X versions:use-latest-snapshots -DexcludeReactor=false -DallowSnapshots=true -DallowMajorUpdates=true -DallowMinorUpdates=true

他为所有外部库正确设置了版本,但不是反应器列表中的内部库。我添加了一些调试输出以显示命令中巧妙地使用了变量。我缩短了 reactorProjects 的输出,但所有项目都正确列出了 afaik。 当我有

的依赖项时也在日志中
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.19.4</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.19.4</version>
    </dependency>
    <dependency>
        <groupId>nl.blablub</groupId>
        <artifactId>dao</artifactId>
        <version>2.0.0-SNAPSHOT</version>
    </dependency>

例如。我看到他搜索球衣部件而不是内部部件。

[DEBUG]   (f) allowIncrementalUpdates = true
[DEBUG]   (f) allowMajorUpdates = true
[DEBUG]   (f) allowMinorUpdates = true
[DEBUG]   (f) allowSnapshots = true
[DEBUG]   (f) excludeReactor = false
[DEBUG]   (f) generateBackupPoms = true
[DEBUG]   (f) localRepository =       id: local
      url: file:///home/xtroce/.m2/repository/
   layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]

[DEBUG]   (f) processDependencies = true
[DEBUG]   (f) processDependencyManagement = true
[DEBUG]   (f) processParent = false
[DEBUG]   (s) project = MavenProject: nl.blablub:libs-mvn:0.0.1-SNAPSHOT @ /home/xtroce/development/blablub-java-repo/libs-mvn/pom.xml
[DEBUG]   (f) reactorProjects = [MavenProject: nl.blablub:libs-mvn:0.0.1-SNAPSHOT @ /home/xtroce/development/blablub-java-repo/libs-mvn/pom.xml, MavenProject: nl.blablub:base-rest-api:2.0.4-SNAPSHOT @ /home/xtroce/development/blablub-java-repo/libs-mvn/base-rest-api/trunk/pom.xml, ... ]
[DEBUG]   (f) remoteArtifactRepositories = [      id: public ...

编辑举个例子:

结构将是: 测试 - 子测试-a - 子测试-b

poms 是:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>subtesta</module>
        <module>subtestb</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.5</version>
            </plugin>
        </plugins>

    </build>
    <repositories>

        <repository>
            <id>public</id>
            <name>External Dependencies</name>
            <url>http://localhost:8081/repository/maven-public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <!-- pull from Release Repository -->
        <repository>
            <id>minc-releases</id>
            <name>Release Directory</name>
            <url>http://localhost:8081/repository/maven-releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <!-- pull from Snapshot Repository -->
        <repository>
            <id>minc-snapshots</id>
            <name>Snapshot Repository</name>
            <url>http://localhost:8081/repository/maven-snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

子测试-a的pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>test</artifactId>
        <groupId>test</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>subtest-a</artifactId>
    <version>1.0-SNAPSHOT</version>

</project>

子测试-b的pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>test</artifactId>
        <groupId>test</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>subtest-b</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.19</version>
    </dependency>
    <dependency>
        <groupId>test</groupId>
        <artifactId>subtest-a</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    </dependencies>
</project>

步数:我愿意 mvn 全新安装

构建良好,接下来: 将 subtest-a 的版本号增加到 1.1-SNAPSHOT

下一个: mvn 安装

我现在可以在我的 ~/.m2/repository

中看到 1.1-SNAPSHOT

接下来我运行给出的命令

mvn -X versions:use-latest-snapshots -DexcludeReactor=false -DallowSnapshots=true -DallowMajorUpdates=true -DallowMinorUpdates=true

他没有增加版本号,即使更高版本出现在反应器包中,并且不忽略反应器内容的正确变量已提供给 Maven。在调试中我看到他甚至没有尝试获取 subtest-a 项目的版本号。

如果我 运行 与 use-latest-release 相同的命令他将球衣的版本号从 1.19 增加到 1.19.4 因此插件适用于外部依赖项,但不适用于通过反应器。

释放本地存储库的 lockFile 时出错,但这可能与此有关,但我对此表示怀疑,因为我什至没有在 subtest-b 项目依赖项清单中看到 subtest-a 依赖项.

我把带有调试输出的日志放在 pastebin 上

https://pastebin.com/NNaSu5DJ

编辑 2

将所有版本更新到非 SNAPSHOT 版本并使用目标 "use-latest-release" 和相同的命令行选项进行测试时,一切都按预期进行。如果 subtest-a 更改了版本,则 subtest-b 的版本也会更新。所以这似乎是使用最新快照部分的一些错误。

问题是我没能正确阅读文档。 它指出

versions:use-latest-snapshots searches the pom for all non-SNAPSHOT versions which have been a newer -SNAPSHOT version and replaces them with the latest -SNAPSHOT version.

问题是我尝试更新 SNAPSHOT 版本,而文档指出这是不可能的。当使用 "use-latest-versions" 我可以做我想做的事。

versions:use-latest-versions searches the pom for all versions which have been a newer version and replaces them with the latest version.