GeezerVison is showing github.com — Handling of Java versions like 21.0.10.0.1 fails · Issue #966 · apache/maven-enforcer
Handling of Java versions like 21.0.10.0.1 fails #966Labels bugSomething isn't working DescriptionAffected version
all
Bug description
The newest SapMachine 21 release has the version string "21.0.10.0.1". When passing this version string directly into the enforcer plugin via:
<configuration>
<rules>
<requireJavaVersion>
<version>21.0.10.0.1</version>
</requireJavaVersion>
</rules>
</configuration>
It fails when running on such a Java release (the problem is not SapMachine specific):
[ERROR] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion failed with message:
[ERROR] Detected JDK /Users/i560383_1/Downloads/sapmachine-jdk-21.0.10.0.1.jdk/Contents/Home is version 21.0.10-0 which is not in the allowed range [21.0.10.0.1,).
This is due to only the normalized (broken here) version string is compared with the actual version.
Code sample in https://github.com/parttimenerd/sapmachine-21.0.10.0.1-demo Activitycstamas commented on Mar 24, 2026 Error message contains reported version, and it is 21.0.10-0, not 21.0.10.0.1, and Enforcer seems right:
[cstamas@angeleyes ~]$ jbang --main=org.eclipse.aether.util.version.GenericVersionScheme org.apache.maven.resolver:maven-resolver-util:1.9.27 21.0.10-0 21.0.10.0.1
Display parameters as parsed by Maven Resolver (in canonical form and as a list of tokens) and comparison result:
1. 21.0.10-0 -> 21.0.10-0; tokens: [21, 0, 10]
21.0.10-0 < 21.0.10.0.1
2. 21.0.10.0.1 -> 21.0.10.0.1; tokens: [21, 0, 10, 0, 1]
[cstamas@angeleyes ~]$
And finally:
[cstamas@angeleyes ~]$ java -version
openjdk version "21.0.10" 2026-01-20 LTS
OpenJDK Runtime Environment SapMachine (build 21.0.10+7-LTS)
OpenJDK 64-Bit Server VM SapMachine (build 21.0.10+7-LTS, mixed mode, sharing)
[cstamas@angeleyes ~]$ jshell
| Welcome to JShell -- Version 21.0.10
| For an introduction type: /help intro
jshell> System.getProperty("java.version")
$1 ==> "21.0.10"
jshell>
[cstamas@angeleyes ~]$
parttimenerd commented on Mar 24, 2026 ContributorAuthor More actions No, you're using a different SapMachine version.
> java -version
openjdk version "21.0.10.0.1" 2026-02-17 LTS
OpenJDK Runtime Environment SapMachine (build 21.0.10.0.1+1-LTS)
OpenJDK 64-Bit Server VM SapMachine (build 21.0.10.0.1+1-LTS, mixed mode, sharing)
The Java version is "21.0.10.0.1" (see https://github.com/SAP/SapMachine/releases/tag/sapmachine-21.0.10.0.1). parttimenerd commented on Mar 24, 2026 ContributorAuthor More actions In my opinion:
<configuration>
<rules>
<requireJavaVersion>
<version>${java.version}</version>
</requireJavaVersion>
</rules>
</configuration>
With ${java.version} being the system property "java.version" of the JVM running the maven version should always succeed.
We literally require the same Java version as we're currently running with. But it doesn't because of the normalization. parttimenerd commented on Mar 24, 2026 ContributorAuthor More actions Thanks for taking a look at this issue. I provided my fix proposal in #967. Bukama commented on Mar 25, 2026 Version Range detection is buggy anyway (see my additional tests in #949) parttimenerd commented on Mar 25, 2026 ContributorAuthor More actions I saw it. But hopefully my PR could be fixed to at least support this common CI pattern properly parttimenerd commented on May 14, 2026 ContributorAuthor More actions Should be fixed with the merged PR.
MetadataMetadatabugSomething isn't working DevelopmentNo branches or pull requestsIssue actions
|