2

I am implementing the Maven versions plugin to manage our dependencies, but am having trouble excluding the next Spring major release due to the ".RELEASE" suffix.

Here's a snippet of my pom.xml:

<properties>
     <spring.version>4.2.0.RELEASE</spring.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>[${spring.version},5.0.0.RELEASE)]</version>
    <dependency>
</dependencies>

What I am trying to do is update to the latest 4.X.X (4.3.something) WITHOUT allowing the 5.0 series which could introduce breaking changes. Unfortunately, due to the suffix, it ignores the ")" which is supposed to ignore the 5.0.0 releases.

I do not currently have an externalized rules XML file (getting to it). Can anyone assist?

Edit: I am using the following command to update:

mvn versions:use-latest-releases

Edit 2: Below is my configuration for the maven plugin:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <allowIncrementalUpdates>true</allowIncrementalUpdates>
                    <allowMinorUpdates>true</allowMinorUpdates>
                    <allowMajorUpdates>false</allowMajorUpdates>
                    <allowSnapshots>false</allowSnapshots>
                </configuration>
            </plugin>
Jason
  • 3,943
  • 12
  • 64
  • 104
  • What exactly are you doing with the versions plugin? Which goal are you calling? – J Fabian Meier Oct 01 '19 at 13:18
  • Updated, just using the "regular" use-latest-releases goal. – Jason Oct 01 '19 at 13:34
  • But why do you have the version range, then? – J Fabian Meier Oct 01 '19 at 13:35
  • Because I want to update to the latest minor release, 4.3.X, but not the newest major release in the 5.X series. – Jason Oct 01 '19 at 13:37
  • AFAIK, version ranges are not respected by this plugin. Instead, you need parameters like `allowMajorUpdates`. – J Fabian Meier Oct 01 '19 at 13:39
  • The format I used to specify comes directly from the docs: https://www.mojohaus.org/versions-maven-plugin/examples/update-properties.html – Jason Oct 01 '19 at 13:42
  • These are the docs for `versions:update-properties`. – J Fabian Meier Oct 01 '19 at 13:46
  • 2
    https://www.mojohaus.org/versions-maven-plugin/use-latest-releases-mojo.html use the `allowMajorReleases` flag set to false. `mvn versions:use-latest-releases -DallowMajorUpdates=false` and it should only touch minor or patch versions. – Darren Forsythe Oct 01 '19 at 14:02
  • @DarrenForsythe Generally, this should work. I am just not sure whether `5.0.0.RELEASE` < `5.0.0` which might cause some trouble. The version ordering in Maven is not completely trivial. – J Fabian Meier Oct 01 '19 at 14:21
  • I have edited my question, but JF Meier pointed me in the right direction. One final question: Can the plugin change the property to the newest version WITHOUT the manual method of using ```versions:set-property``` ? – Jason Oct 01 '19 at 14:22

0 Answers0