1

I am currently implementing a Jenkins job whose goal is to call the Maven versions:display-dependency-updates in order to find the latest available incremental updates for my dependencies.

However the plugin does not manage to find updates for dependencies for which the major version are like develop. Indeed, I am referencing other internal projects in my project's dependencies, all of them begin on develop versions until we branch to a release branch, where we will reference the needed release version.

I have a dedicated POM to manage those versions, it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>groupid</groupId>
        <artifactId>root</artifactId>
        <version>develop-SNAPSHOT</version>
    </parent>
    <artifactId>external-dependencies</artifactId>
    <packaging>pom</packaging>
    <properties>
        <dep1.version>2.3.18</dep1.version>
        <dep1.majorversion>2.3</dep1.majorversion>
        <dep1.version-range>[${dep1.majorversion}.0,${dep1.majorversion}.999)</dep1.version-range>
        <dep2.version>develop.5</dep2.version>
        <dep2.majorversion>develop</dep2.majorversion>
        <dep2.version-range>[${dep2.majorversion}.0,${dep2.majorversion}.999)</dep2.version-range>
        <dep3.version>1.0.1</dep3.version>
        <dep3.majorversion>1.0</dep3.majorversion>
        <dep3.version-range>[${dep3.majorversion}.0,${dep3.majorversion}.999)</dep3.version-range>
        <versions.to.update>
            dep1.version,
            dep2.version
        </versions.to.update>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>dep1.group</groupId>
                <artifactId>dep1.artifact</artifactId>
                <version>${dep1.version}</version>
            </dependency>
            <dependency>
                <groupId>dep2.group</groupId>
                <artifactId>dep2.artifact</artifactId>
                <version>${dep2.version}</version>
            </dependency>
            <dependency>
                <groupId>dep3.group</groupId>
                <artifactId>dep3.artifact</artifactId>
                <version>${dep3.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <includeProperties>${versions.to.update}</includeProperties>
                    <allowMajorUpdates>false</allowMajorUpdates>
                    <properties>
                        <property>
                            <name>dep1.version</name>
                            <version>${dep1.version-range}</version>
                        </property>
                        <property>
                            <name>dep2.version</name>
                            <version>${dep2.version-range}</version>
                        </property>
                    </properties>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

So when I run mvn versions:display-property-updates -DallowMajorUpdates=false the result will show me potential updates of dep1, but not of dep2. However, removing the allowMajorUpdates option would return me potential updates on develop.

My understanding would be that Maven does some assumption on the version format, being numerical for instance, so it does not understand develop as a valid version and skips the execution.

In the end, I'd like to be able to use the allowMajorUpdates option because I would prefer to not check for new released versions of a dependency (we get the information from other channels), but then I won't get my develop updates seen...

Is there any way to make Maven check, on top of its own rules for comparison, formats like this develop?

Thanks

Xendar
  • 466
  • 1
  • 6
  • 15
  • 1
    While there might be a way to solve your problem, I would seriously think about moving away from non-numeric versions. They might break implicit and explicit assumptions of different Maven plugins. Why not use `1.2.3-SNAPSHOT` or `1.2.3-development-SNAPSHOT` ? – J Fabian Meier Aug 13 '18 at 12:52
  • Well, that could be an option, but everybody is using this kind of "convention" in the company. but with this kind of version like `1.2.3-development`, would a `mvn versions:update-property` work? – Xendar Aug 13 '18 at 13:00
  • First I would really reconsider to think your "convention" in the company cause Maven is opinionated is some ways which make sense...The question is: `1.2.3-development` is from the point of view of Maven a release which I think is not intended...As already @JFMeier mentioned better is to go with a SNAPSHOT...Furthermore `develop.5` given in your example you should think how Maven compares versions...furthermore I would suggest to go via semver and go with numerical ways...it is one thing a company convention and a universal convention...? – khmarbaise Aug 13 '18 at 17:35
  • OK, I can try to fight the battle to move to semver, which would be indeed the good thing to do. But now I was more interested in understanding better how Maven behaves and handles this kind of things. – Xendar Aug 14 '18 at 15:36

0 Answers0