Maven 执行器插件因打开的 JDK 中的版本字符串而崩溃 [英] Maven enforcer plugin crashing because of version string in open JDK

查看:62
本文介绍了Maven 执行器插件因打开的 JDK 中的版本字符串而崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了 open jdk 并且在 maven 构建方面遇到了一些问题,特别是 maven-enforcer-plugin.使用插件版本 1.4.1.

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

Enforcer 插件正在尝试强制执行 JDK 版本,例如

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 插件崩溃并出现以下错误

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)

花了很多时间,我终于发现JDK是报告版本,没有小数点.这导致插件失败.

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?

推荐答案

基于 最近的来源 它仍在使用 commons-lang 来检测 Java 版本.这个实现有一些问题并且不向前兼容.我已经创建了 MENFORCER-347,这应该很容易解决.我已将其标记为 up-for-grabs,因此它将显示在 列表中https://s.apache.org/up-for-grabs_maven 并希望有人会拿起它.

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.

这篇关于Maven 执行器插件因打开的 JDK 中的版本字符串而崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆