Maven versions plugin with non numeric version

577 views Asked by At

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

0

There are 0 answers