1

我正在使用versions-maven-plugin,并且在我的顶级pom.xml 中有几个用于versions-maven-plugin 的配置:

<build>
    <pluginManagement>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>2.8.1</version>
            <configuration>
                <properties>
                    <property>
                        <name>magic-tool.version</name>
                    </property>
                </properties>
            </configuration>
        </plugin>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
        </plugin>
...
<reporting>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <reportSets>
               <reportSet>
                    <reports>
                        <report>dependency-updates-report</report>
                        <report>plugin-updates-report</report>
                        <report>property-updates-report</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>

还有一个引用内部存储库“魔术工具”的属性:

<properties>
     <magic-tool.version>100</magic-tool.version>

有问题的命令是

mvn clean && mvn versions:update-properties versions:commit -N -U -DincludeProperties=magic-tool.version -DallowSnapshots=true -X

这比指定确切的版本更可取,因为它将在 TeamCity 中使用 - 此命令在另一个具有几乎相同的 pom.xml 和完全相同的配置的应用程序中完美运行!

然而,非功能性应用程序的输出是

[DEBUG] lowerBoundArtifactVersion: 100
[DEBUG] Property ${magic-tool.version}: Current winner is: null
[INFO] Property ${magic-tool.version}: Leaving unchanged as 100

当我们的仓库中的魔术工具在 v102 上时,而我们正常工作的应用程序输出:

[DEBUG] Property ${magic-tool.version}: Set of valid available versions is [1, 2, 3, 4, 5, 6, 7... 95, 96, 97, 98, 99, 100, 101, 102]
[DEBUG] Property ${magic-tool.version}: Restricting results to null
[DEBUG] lowerBoundArtifactVersion: 101
[DEBUG] Property ${magic-tool.version}: Current winner is: 102
[DEBUG] Property ${magic-tool.version}: Searching reactor for a valid version...
[DEBUG] Property ${magic-tool.version}: Set of valid available versions from the reactor is []
[INFO] Updated ${magic-tool.version} from 100 to 102

如何让非功能性应用程序更新此属性 magic-tool.version?

4

1 回答 1

0

答案是该属性在 中未使用,non-functional > parent pom > dependencies但在 中使用functional app > parent pom > dependencies

该命令是非递归的,因此它不知道magic-tool.versionnon-functional app > child poms > dependencies.

解决方案是在顶级 pom 中主动使用/定义依赖项中的属性(注意添加它<dependencyManagement>什么也没做)。

于 2021-02-11T17:38:36.793 回答