Search code examples
javamavenmaven-3maven-versions-pluginscalatest-maven-plugin

Exclude property using mvn versions:update-properties with excludesList


I'm using mvn versions:update-properties -DexcludesList=org.scalatest:scalatest* to exclude update of property scalatest.version inside pom.xml:

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

But after running the command scalatest.version is updated to 3.3.0-SNAP2 version which is the latest.

How to use -DexcludesList argument correctly? I followed the docs

The only workaround i found is excluding SNAP2 versions in rules.xml like below:

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

And running mvn versions:update-properties -Dmaven.version.rules=file:////tmp/rules.xml -DexcludesList=org.scalatest:scalatest*

This way scalatest is updated to 3.2.2. I'd like to ignore update of scalatest version completely.

Tried different variations: -DexcludesList=org.scalatest:scalatest:*, -DexcludesList=org.scalatest:scalatest:*:*:* to no avail.

Using version 2.1 of versions-maven-plugin, updated to latest 2.8.1 and still scalatest was updated.


Solution

  • The solution was to use -DexcludeProperties=scalatest.version argument.

    mvn versions:update-properties -DexcludeProperties=scalatest.version achieved what i needed.

    The docs