4
votes

I am using Maven Versions plugin's update-properties goal to update properties in pom.xml of multiples projects. (https://www.mojohaus.org/versions-maven-plugin/update-properties-mojo.html). I want the latest version of the dependency for properties.

Now, there are some binaries with wrong versions. I want my code to ignore these versions. For this, I have created my "rules.xml" file. I want to provide it as -DrulesUri argument to update-properties goal.

I already tried specifying this rules.xml file in pom.xml file of project as shown on (Maven versions plugin: reference a rule.xml from a maven dependency?). This worked as the plugin could successfully ignore specified versions in rules.xml. So, there is no problem with rules.xml file. But, this is not useful in my case, since there are many projects involved and I cannot update pom.xml of each project.

The documentation of rulesUri property says "URI of a ruleSet file containing the rules that control how to compare version numbers. The URI could be either a Wagon URI or a classpath URI (e.g. classpath:///package/sub/package/rules.xml)." This much documentation is not helping me. I would want an example on how to specify the rules.xml file in -DrulesUri argument. I tried specifying the rules.xml file as local relative path / absolute path. But, update-properties goal does not seem to recognize the rules and just proceeds similar to execution without -DrulesUri argument. I tried reading https://maven.apache.org/wagon/ to understand Wagon URIs. But, I did not find a simple way to upload my rules.xml somewhere and then use this Wagon URI to specify in -DrulesUri.

This is my rules.xml file :-

<?xml version="1.0" encoding="UTF-8"?>
<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">25243.*.*</ignoreVersion>
    </ignoreVersions>
    <rules>
    </rules>
</ruleset>
1

1 Answers

2
votes

Use -Dmaven.version.rules

Example:

mvn versions:display-dependency-updates -Dmaven.version.rules=file:///$HOME/.m2/rules.xml

From AbstractVersionsReport.java source code:

    /**
     * URI of a ruleSet file containing the rules that control how to compare
     * version numbers. The URI could be either a Wagon URI or a classpath URI
     * (e.g. <code>classpath:///package/sub/package/rules.xml</code>).
     *
     * @since 1.0-alpha-3
     */
    @Parameter( property = "maven.version.rules" )
    private String rulesUri;