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

Benjamin Marwell edited comment on MENFORCER-288 at 12/14/19 5:47 PM:
----------------------------------------------------------------------

I came to the conclusion that this cannot be easily and might not be worth the 
effort.

Rationale:

`<requireJavaVersion>` takes a *version range*. You had to parse the version 
range and convert each element into a java version. If {{<="}}8" (beware of 
String parsing), add a "{{1.}}" prefix. I do not think that this plugin should 
fiddle with a version range. The VersionRange would need to parse into a 
modifiable element set for this, which is not supported at the moment.Example: 
{color:#0747a6}{{(,6.0.5],[7.1.1,)}}{color} would need to get converted to 
{color:#0747a6}{{(,1.6.0-5],[1.7.1-1,)}}{color}.

Also, while the JEP is implemented by 
[https://codehaus-plexus.github.io/plexus-languages/plexus-java/apidocs/org/codehaus/plexus/languages/java/version/JavaVersion.html]
 is not helpful. There is no `normalize()` method which would spill out `1.6` 
for 6, and the `asMajor()` method would spill out `6` for `1.6`, which is not 
helpful either. Also, no JVM would ever identify itself as "`6`".

 


was (Author: mampf86):
I came to the conclusion that this cannot be easily and might not be worth the 
effort.

Rationale:

`<requireJavaVersion>` takes a *version range*. You had to parse the version 
range and convert each element into a java version. If {{<="}}8" (beware of 
String parsing), add a "{{1.}}" prefix. I do not think that this plugin should 
fiddle with a version range. The VersionRange would need to parse into a 
modifiable element set for this, which is not supported at the moment.Example: 
{color:#0747a6}{{(,6.0.5],[7.1.1,)}}{color} would need to get converted to 
{color:#0747a6}{{(,1.6.0-5\{{],[}}1.7.1-1,)}}{color}.

Also, while the JEP is implemented by 
[https://codehaus-plexus.github.io/plexus-languages/plexus-java/apidocs/org/codehaus/plexus/languages/java/version/JavaVersion.html]
 is not helpful. There is no `normalize()` method which would spill out `1.6` 
for 6, and the `asMajor()` method would spill out `6` for `1.6`, which is not 
helpful either. Also, no JVM would ever identify itself as "`6`".

 

> RequireJavaVersion: Support new Java 9 versioning schema even for older Java 
> versions
> -------------------------------------------------------------------------------------
>
>                 Key: MENFORCER-288
>                 URL: https://issues.apache.org/jira/browse/MENFORCER-288
>             Project: Maven Enforcer Plugin
>          Issue Type: Improvement
>          Components: Standard Rules
>    Affects Versions: 3.0.0-M1
>            Reporter: Konrad Windszus
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Although with MENFORCER-274 it is now possible to specify 
> {code}
>                 <requireJavaVersion>
>                   <version>9</version>
>                 </requireJavaVersion>
> {code}
> it is still not possible to refer to older java versions without the 
> leadering {{1.}}.
> So e.g. this one does not work
> {code}
>                 <requireJavaVersion>
>                   <version>6</version>
>                 </requireJavaVersion>
> {code}
> This would be very handy as with JDK 9 you specify e.g. release only without 
> the preceeding {{1.}} (compare with 
> https://docs.oracle.com/javase/9/tools/javac.htm#GUID-AEEC9F07-CB49-4E96-8BC7-BCC2C7F725C9__GUID-D343F6B4-3FDD-43A8-AD24-43DD70214471).
>  As it is very common to reuse the same Maven property value for enforcing 
> the minimum java version with the {{maven-enforcer-plugin}} as well as for 
> specifying the release/source/target of the {{maven-compiler-plugin}} it 
> would be nice, if both support the same version range.
> To still be backwards compatible I would suggest that in case of 6,7,8 given 
> as a value, the {{1.}} is implicitly prepended by the 
> {{maven-enforcer-plugin}}.



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

Reply via email to