5

Trying to migrate Maven from Java 9 to Java 10 produces errors in the pom.xml ,the maven-compiler-plugin doesn't work :

Java 9 Configuration (works more than great):

<plugin>                                               
    <groupId>org.apache.maven.plugins</groupId>        
    <artifactId>maven-compiler-plugin</artifactId>     
    <version>3.7.0</version>                           
    <configuration>                                    
        <source>1.9</source>                           
        <target>1.9</target>                           
        <release>9</release>                           
        <executable>javac9</executable>                
        <encoding>UTF-8</encoding>                     
    </configuration>                                   
</plugin>     

Java 10 Configuration ( fails ) based on this stackoverflow question:

<plugin>                                                                   
    <groupId>org.apache.maven.plugins</groupId>                            
    <artifactId>maven-compiler-plugin</artifactId>                         
    <version>3.7.0</version>                                               
    <configuration>                                                        
        <source>10</source>                                                
        <target>10</target>                                                
        <release>10</release>                                              
        <executable>javac10</executable>                                   
        <encoding>UTF-8</encoding>                                         
    </configuration>                                                       
    <dependencies>                                                         
        <dependency>                                                       
            <groupId>org.ow2.asm</groupId>                                 
            <artifactId>asm</artifactId>                                   
            <version>6.1.1</version> <!-- Use newer version of ASM -->     
        </dependency>                                                      
    </dependencies>                                                        
</plugin>   

Error on mvn clean package :

[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ XR3Player ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 164 source files to D:\GitHub\XR3Player\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.915 s
[INFO] Finished at: 2018-04-24T18:12:17+03:00
[INFO] Final Memory: 14M/48M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project XR3Player: Fatal error compiling: release version 10 not supported -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93
  • it works for me, what is your maven version? – nitnamby Apr 24 '18 at 15:40
  • @nitnamby 3.5.3 latest Maven Version https://maven.apache.org/download.cgi and using ``Eclipse Photon M6 latest version`` – GOXR3PLUS Apr 24 '18 at 15:40
  • did you try it from command line? – nitnamby Apr 24 '18 at 15:43
  • @nitnamby Yes exactly :) For Java 10 it produces the same error ```Fatal error compiling: release version 10 not supported``` did you run it and it works ? How is this possible ... i am confused . – GOXR3PLUS Apr 24 '18 at 15:46
  • 2
    do you have multiple maven versions? – nitnamby Apr 24 '18 at 15:52
  • @nitnamby Only one 3.5.3 , currently checking if it is an Eclipse Problem , changing to Eclipse Oxygen.3 to see :) – GOXR3PLUS Apr 24 '18 at 15:54
  • if you get the same issue when you run it outside eclipse then changing eclipse version won't help – nitnamby Apr 24 '18 at 15:57
  • @nitnamby Everything ok with Eclipse Oxygen.3 it supports Java 10 by default , i tried this answer also from StackOverflow -> https://stackoverflow.com/questions/49436841/how-to-set-up-java-10-in-eclipse-oxygen . It doesn't works . – GOXR3PLUS Apr 24 '18 at 15:58
  • @nitnamby I think i see where is the problem , i have multiple java versions on the Machine ``Java 8,9,10`` a ``mvn -version``` returns ```Java version: 9.0.4, vendor: Oracle Corporation``` hm gonna see how i can change it accordingly . – GOXR3PLUS Apr 24 '18 at 15:59
  • 2
    maven uses JAVA_HOME to detect java version – nitnamby Apr 24 '18 at 16:00
  • @nitnamby Yes i missed it , searching how to use different Java version for each mvn call , beacause i am using all ```Java 8 , Java 9 and Java 10 for different Maven Projects``` – GOXR3PLUS Apr 24 '18 at 16:02
  • 2
    Your build does not correctly use JDK 10...it uses (assumption) JDK 9....either you correctly configure JAVA_HOME or your start using toolchains to correctly handle that... – khmarbaise Apr 24 '18 at 16:53
  • @khmarbaise Thanks currently reading Maven toolchains tutorials and gonna add an answer here :) – GOXR3PLUS Apr 24 '18 at 17:15

0 Answers0