Issue
When I'm running versions:display-dependency-updates
, it will show all the newest beta / milestone versions of my dependencies. I prefer using "release" packages.
versions:use-latest-releases
talks about "replacing" with the latest release version. However, I prefer updating the versions manually.
Can I run the versions plugin to give me a report on the latest "release" versions of my dependencies and plugins?
I am referring to the "type" of the package as listed on mvnrepository.org
Solution
Two steps
Add rulesUri
to the plugin configuration
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<rulesUri>file:///${project.basedir}/rules.xml</rulesUri>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
Add the rules.xml
file to your project root directory.
<?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>
<!-- Ignore Alpha's, Beta's, release candidates and milestones -->
<ignoreVersion type="regex">(?i).*Alpha(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*a(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*Beta(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*-B(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*RC(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*CR(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*M(?:-?\d+)?</ignoreVersion>
</ignoreVersions>
<rules>
</rules>
</ruleset>
The regex filters out the unstable releases. You can also target rules for specific dependencies, see:
http://blog.xebia.com/keeping-dependencies-up-to-date-in-maven/
https://gist.github.com/seahrh/b13f4f3d618ad7c817038e0bc124ef29
Version rules will also stay for future releases of the plugin.
Answered By - ruhong
Answer Checked By - Senaida (JavaFixing Volunteer)