5

I am trying to create web app using spring boot, maven and java 12. I started the project with spring-boot-starter-parent version 2.1.5.RELEASE, java 12 and maven-compiler-plugin version 3.8.1. I tried to run ./mvnw package but i got this error:

Fatal error compiling: invalid target release: 12

After that i wrote on the internet that maven compiler plugin uses old dependency for asm and i should specify new version of it. So i selected the latest version of asm which is 7.1 and i added configuration tag with properties release 12 and compilerArgs --enable-preview for java 12. The result was:

Fatal error compiling: invalid flag: --release

The next thing that i tried was to use spring boot starter parent version 2.2.0.M3 and to specify the repository to find milestone versions of spring from http://repo.spring.io/milestone. Unfortunately i got the same result. Any ideas?

Angel
  • 193
  • 1
  • 3
  • 15
  • `invalid flag: --release` indicates `javac` version below Java-9 in use. – Naman Jun 07 '19 at 10:23
  • 1
    @ThorbjørnRavnAndersen I doubt that, few links to prove that it supports Java-12 and might help people looking for a solution to a similar error - [Compile a JDK12 preview feature with Maven](https://stackoverflow.com/questions/52232681/compile-a-jdk12-preview-feature-with-maven) and [Error:java: error: invalid source release: 13 using JDK12 with IntelliJ](https://stackoverflow.com/questions/54156370/errorjava-error-invalid-source-release-13-using-jdk12-with-intellij). – Naman Jun 07 '19 at 10:48
  • @ThorbjørnRavnAndersen Why does maven-compiler-plugin not support JDK12 ? In which way? The Maven Team is running tests with JDK 12 and JDK13+EA ? – khmarbaise Jun 07 '19 at 20:16

1 Answers1

7

Trying with previous versions to spring boot 2.2.0.MX it also failed for me, but I have managed to make it work with 2.2.0.M6 including some plugins and tweaking them to adapt with the preview features like:

       <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <arguments>--enable-preview</arguments>
                    <jvmArguments>--enable-preview</jvmArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <argLine>--enable-preview</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <compilerArgs>--enable-preview</compilerArgs>
                </configuration>
            </plugin>
       </plugins>    

This is now working with Java 13.

Jaumzera
  • 2,305
  • 1
  • 30
  • 44