3

I downloaded open jdk and having some issues with maven build, specifically, maven-enforcer-plugin. Using plugin version 1.4.1.

Enforcer plugin is trying to enforce JDK version like

<requireJavaVersion>
    <version>[13,)</version>
    <message>[ERROR] OLD JDK [${java.version}] in use. Need JDK 13.0 or newer</message>
</requireJavaVersion>

Enforcer plugin crashes with following error

Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2
    at java.lang.String.checkBoundsBeginEnd (String.java:3319)
    at java.lang.String.substring (String.java:1874)
    at org.apache.commons.lang.SystemUtils.getJavaVersionAsFloat (SystemUtils.java:1122)
    at org.apache.commons.lang.SystemUtils.<clinit> (SystemUtils.java:818)
    at org.apache.maven.plugins.enforcer.RequireJavaVersion.execute (RequireJavaVersion.java:52)
    at org.apache.maven.plugins.enforcer.EnforceMojo.execute (EnforceMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

After spending lot of time, I finally figured out JDK is reporting version which does not have decimal point. This is causing the plugin to fail.

java -version
   openjdk version "13" 2019-09-17
   OpenJDK Runtime Environment (build 13+33)
   OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)

What will be the workaround in this situation?

user871199
  • 1,420
  • 19
  • 28

1 Answers1

0

Based on the recent sources it is still using commons-lang to detect the Java version. This implementation has some issues and is not forward compatible. I've created MENFORCER-347, which should be an easy fix. I've marked it as up-for-grabs, so it'll show up in the list of https://s.apache.org/up-for-grabs_maven and hopefully somebody will pick it up.

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44