maven版本插件不会更新reactor

时间:2018-03-23 16:54:25

标签: maven maven-versions-plugin

我目前正在尝试通过maven的版本插件更新内部库的依赖项。该插件整齐地更新了外部库,但mulitmodule库没有任何变化。

描述我之前做过的事情

我之前构建它们,因此文件存在新版本。

在每个子模块上我使用的版本:设置为设置一个新版本(我通过不同的子模块循环,因为主项目中的每个lib的主要版本和次要版本可能不同)并且它们与旧版本成功链接。

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

执行时:

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 ...

编辑以提供示例项目:

结构将是: 测试   - subtest-a   - subtest-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>

subtest-a:

<?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>

subtest-b:

<?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 clean install

它构建正常,下一个:     将subtest-a的版本号增加到1.1-SNAPSHOT

下:     mvn install

我现在可以在〜/ .m2 / repository

中看到1.1-SNAPSHOT

接下来我运行给定的命令

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

他没有增加版本号,即使更高版本出现在反应堆包中,并且没有忽略反应堆内容的正确变量被赋予maven。在调试中我看到他甚至没有尝试获得子测试的版本号 - 一个项目。

如果我使用use-latest-release运行相同的命令,他会将jersey的版本号从1.19增加到1.19.4,因此插件适用于外部依赖项,但不适用于通过reactor提供的依赖项。

发布本地仓库的lockFile时出错,但这可能与此有关,但我对此表示怀疑,因为我甚至看不到子测试 - subtest-b项目依赖项核对表中的依赖项

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

https://pastebin.com/NNaSu5DJ

编辑2

将所有版本更新为非SNAPSHOT版本并按目标&#34进行测试时;使用-latest-release&#34;和相同的命令行选项一切按预期工作。如果subtest-a更改版本,则更新subtest-b的版本。因此,使用最新快照部分似乎是一些错误。

1 个答案:

答案 0 :(得分:1)

问题是我无法正确阅读文档。 它说明了

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.