Exclude release candidates in Versions Maven Plugin

1.6k views Asked by At

How can I configure the Versions Maven Plugin to exclude release candidates of certain dependencies? The versions of the dependencies in question have following format:

\d+\.\d+\.\d+\.\d+(-rc\d+)? OR <major>.<minor>.<sub>.<incremental>(-rc<number>)

E.g. 4.6.5.2 or 4.6.7.0-rc10. So release candidates are only distinguised by their additional suffix. There is no separate maven repository etc.


I'm using org.codehaus.mojo:versions-maven-plugin in version 2.5.

1

There are 1 answers

0
mike On BEST ANSWER

Update the pom.xml with

<build>
   <plugins>
      <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>versions-maven-plugin</artifactId>
         <version>2.5</version>
         <configuration>
            <rulesUri>file://${session.executionRootDirectory}/version-rules.xml</rulesUri>
         </configuration>
      </plugin>
   </plugins>
</build>

and define follwing rule set in version-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 https://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
    <rules>
        <rule groupId="com.example">
            <ignoreVersions>
                <ignoreVersion type="regex">(\d+\.\d+\.\d+\.\d+)-(rc\d+)
                </ignoreVersion>
            </ignoreVersions>
        </rule>
    </rules>
</ruleset>

Rules can be defined per groupId, as shown above, or globally, if you put

<ignoreVersions>
   <ignoreVersion type="regex">(\d+\.\d+\.\d+\.\d+)-(rc\d+)</ignoreVersion>
</ignoreVersions>

under the ruleset element.