为什么 Maven 版本插件不更新本地定义的 属性?

Why doesn't Maven versions plugin update the locally defined property?

我正在使用 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>

还有一个 属性 指的是内部存储库“magic-tool”:

<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

当 magic-tool 在我们的 repo 中使用 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?

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

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

中使用

解决方案是主动use/define顶层pom中的依赖项中的属性(注意添加到<dependencyManagement>没有任何作用)。