使用mvn版本排除属性:带有excludesList

问题描述

我正在使用mvn versions:update-properties -DexcludesList=org.scalatest:scalatest*排除pom.xml中属性scalatest.version的更新:

<properties>
    <scalatest.version>3.0.5</scalatest.version>
</properties>

但是在运行命令scalatest.version后,其版本已更新为3.3.0-SNAP2,即latest

如何正确使用-DexcludesList参数?我关注了docs

我发现的唯一解决方法是排除SNAP2中的rules.xml版本,如下所示:

<ruleset xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" comparisonMethod="maven" xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
    <ignoreversions>
        <ignoreversion type="regex">9.*</ignoreversion>
        <ignoreversion type="regex">6.1.*</ignoreversion>
        <ignoreversion type="regex">.*SNAP.*</ignoreversion>
    </ignoreversions>
    <rules>
    </rules>
</ruleset>

并运行mvn versions:update-properties -Dmaven.version.rules=file:////tmp/rules.xml -DexcludesList=org.scalatest:scalatest*

通过这种方式,scalatest被更新为3.2.2。我想完全忽略scalatest版本的更新。

尝试了各种变化:-DexcludesList=org.scalatest:scalatest:*-DexcludesList=org.scalatest:scalatest:*:*:*无济于事。

使用versions-maven-plugin的2.1版,已更新为最新的2.8.1,而scalatest仍已更新。

解决方法

解决方案是使用-DexcludeProperties=scalatest.version参数。

mvn versions:update-properties -DexcludeProperties=scalatest.version实现了我所需要的。

docs