You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Scholte (Jira)" <ji...@apache.org> on 2020/03/22 11:54:00 UTC

[jira] [Comment Edited] (MENFORCER-347) RequireJavaVersion should use plexus-java

    [ https://issues.apache.org/jira/browse/MENFORCER-347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17064247#comment-17064247 ] 

Robert Scholte edited comment on MENFORCER-347 at 3/22/20, 11:53 AM:
---------------------------------------------------------------------

The root problem is [JavaVersion|https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/JavaVersion.java] combined with the following line in  SystemUtils: 
{{private static final JavaVersion JAVA_SPECIFICATION_VERSION_AS_ENUM = JavaVersion.get(JAVA_SPECIFICATION_VERSION);}}

This means that once the SystemUtils class is initialized, it will also initialize this field. However, if the enum doesn't exist yet, then you can't use SystemUtils at all. 
It must be possible to call something like this right now:
{code:xml}
<requireJavaVersion>
    <version>17</version>
</requireJavaVersion>
{code}
even though the version doesn't exist yet.


was (Author: rfscholte):
The root problem is [JavaVersion|https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/JavaVersion.java] combined with the following line in  SystemUtils: 
{{private static final JavaVersion JAVA_SPECIFICATION_VERSION_AS_ENUM = JavaVersion.get(JAVA_SPECIFICATION_VERSION);}}

This means that once the SystemUtils class is initialized, it will also initialize this field. However, if the enum doesn't exist yet, then you can't use SystemUtils at all. 
It must be possible to call something like this right now:
{code:xml}
<requireJavaVersion>
    <version>17</version>
</requireJavaVersion>
<code}
even though the version doesn't exist yet.

> RequireJavaVersion should use plexus-java
> -----------------------------------------
>
>                 Key: MENFORCER-347
>                 URL: https://issues.apache.org/jira/browse/MENFORCER-347
>             Project: Maven Enforcer Plugin
>          Issue Type: Improvement
>          Components: Standard Rules
>            Reporter: Robert Scholte
>            Priority: Minor
>              Labels: up-for-grabs
>
> This rule is using {{SystemUtils.JAVA_VERSION}} to verify the Java version. The downside of this solution is that it needs to be updated every 6 month because it is using an enum to verify it.
> Several other plugins already use https://codehaus-plexus.github.io/plexus-languages/plexus-java/usage.html to compare Java versions, and it doesn't require to be updated with every new Java release (as long as it keeps using the same versioning scheme of course)
> Better to replace this piece of code.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)