mojohaus / versions

Versions Maven Plugin
https://www.mojohaus.org/versions/versions-maven-plugin/
Apache License 2.0
337 stars 267 forks source link

Show multiple newer versions for each artifact #1043

Open maffe opened 8 months ago

maffe commented 8 months ago

Sometimes I cannot upgrade to a new major version of a dependency yet. It would be useful to have the plugin report the newest version on each version level (major/minor/patch). For example, if I include io.dropwizard:dropwizard-client:1.0.3, display-dependency-updates currently outputs

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   io.dropwizard:dropwizard-client ....................... 1.0.3 -> 4.0.6

and it should display instead:

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   io.dropwizard:dropwizard-client ......... 1.0.3 -> 1.0.9, 1.3.9, 4.0.6

(5.0.0-alpha.1 is excluded by an ignoreVersion, see my configuration below.)

With this information I can easily decide to upgrade to the latest patch, minor or major version. It is not required to list more than these three versions since it can be assumed that 2.x.y and 3.x.y versions also exist. I could simply include 2.0.0 and would see 2.0.9 and 2.1.9 in the next run.

Another case is when there is no minor or patch update. If I include jakarta.xml.bind:jakarta.xml.bind-api:3.0.1, the output currently is:

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   jakarta.xml.bind:jakarta.xml.bind-api ................. 3.0.1 -> 4.0.1

In this case the output would be the same as before, but knowing about this feature I could assume there is no 3.0.2 or 3.1.0. Or maybe the output could be modified to something like

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   jakarta.xml.bind:jakarta.xml.bind-api .......... 3.0.1 -> 3.0.1, 4.0.1

or

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   jakarta.xml.bind:jakarta.xml.bind-api ........ 3.0.1 -> [3.0.1], 4.0.1

My plugin configuration looks like this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>2.16.0</version>
    <executions>
        <execution>
            <phase>verify</phase>
            <goals>
                <goal>display-parent-updates</goal>
                <goal>display-plugin-updates</goal>
                <goal>display-property-updates</goal>
                <goal>display-dependency-updates</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <ruleSet>
            <ignoreVersions>
                <ignoreVersion>
                    <type>regex</type>
                    <version>(?i).*[.-](?:Alpha|Beta|M|RC)[.-]?[0-9]+</version>
                </ignoreVersion>
            </ignoreVersions>
        </ruleSet>
        <processDependencyManagementTransitive>false</processDependencyManagementTransitive>
    </configuration>
</plugin>