Search code examples
mavenmaven-compiler-plugin

Maven compiler error - invalid flag -- release


I am getting a maven compiler error when compiling with JDK 1.8

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project DUMMY : Fatal error compiling: invalid flag: --release -> [Help 1]

Here is my pom configuration for compiler plugin

            <configuration>
                <source>${maven.compiler.release}</source>
                <target>${maven.compiler.release}</target>
                <release>${maven.compiler.release}</release>
                <jdkToolchain>
                    <version>${maven.compiler.release}</version>
                </jdkToolchain>
                <verbose>false</verbose>
                <useIncrementalCompilation>false</useIncrementalCompilation>
                <executable>${env.JAVA_HOME}/bin/javac</executable>
            </configuration>

Have I configured this incorrectly? Also, this works fine when I have Java 11 for JAVA_HOME, but not with Java 8. Is this expected? Also, from the docs I see that maven.compiler.release is tied with release config anyway. So, does it mean I can ommit the release attribute below and it should be fine?


Solution

  • As mentioned in documentation this argument supported since Java 9, so either change your JDK version or just remove it.