Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 448
ha9u63ar Avatar asked Jul 24 '26 07:07

ha9u63ar


1 Answers

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

like image 83
ginkul Avatar answered Jul 27 '26 15:07

ginkul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!