You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Lugan (Jira)" <ji...@apache.org> on 2021/02/03 07:26:00 UTC

[jira] [Commented] (MCOMPILER-452) release cannot be emptied to activate profiles compiling with previous Java version

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

Lugan commented on MCOMPILER-452:
---------------------------------

Thank you for you reply!
Yes I have seen that properties could not be removed, that's why I tried to empty it.. but found this exception.

I thought that only replacing the line 
{code}
if ( release != null )
{code}
by
{code}
if ( release != null && !release.isEmpty() )
{code}
would be interesting ?!

I workaround my problem by using profiles with and without the variable declaration.

> release cannot be emptied to activate profiles compiling with previous Java version
> -----------------------------------------------------------------------------------
>
>                 Key: MCOMPILER-452
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-452
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.8.1
>            Reporter: Lugan
>            Priority: Minor
>
> I am working on a project where some sub modules maven are in compiled in Java 8, some other in Java 11.
> For modules where sources must be compiled in Java 8, we still want to write our tests in Java 11. 
> I have defined 2 profiles :
>  * Java 11 by default with the maven.compiler.release property set 
>  * Java 8 where the maven.compiler.release property is empty :
>  {code:xml}
> <properties>
>                 <maven.compiler.source>1.8</maven.compiler.source>
>                 <maven.compiler.target>1.8</maven.compiler.target>
>                 <maven.compiler.release></maven.compiler.release>
> </properties>
> {code}
> I have a IllegalArugmentException :
> {code:java}
> Caused by: java.lang.NumberFormatException: For input string: ""
>     at java.lang.NumberFormatException.forInputString (NumberFormatException.java:65)
>     at java.lang.Integer.parseInt (Integer.java:662)
>     at java.lang.Integer.valueOf (Integer.java:983)
>     at org.apache.maven.plugin.compiler.TestCompilerMojo.preparePaths (TestCompilerMojo.java:306)
>  {code}
> After inspecting the plugin source code on github, I have found that release variable is tested to be null or not : 
> {code:java}
> if ( release != null )
>         {
>             if ( Integer.valueOf( release ) < 9 )
>             {
> {code}
> https://github.com/apache/maven-compiler-plugin/blob/master/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
> It would be more robust by checking if release is neither null nor empty. 



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