How does the Maven compiler determine the default source target?

1.1k Views Asked by At

I have a Maven project and in the pom there is nothing like:

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

If I run mvn clean compile and check the bytecode with javap -classpath ../project/target/classes/ -verbose com.xxx.Class I see

minor version: 0
major version: 55

which corresponds to Java 11.

I found the bug ticket MCOMPILER-376 that states that the default version should be 1.7. This is also clearly stated in the plugin documentation:

Also note that at present the default source setting is 1.7 and the default target setting is 1.7, independently of the JDK you run Maven with. You are highly encouraged to change these defaults by setting source and target as described in Setting the -source and -target of the Java Compiler.

I also found a very detailed Stack overflow answer but it did not help me finding the information I am looking for.

I would like to understand how did the Maven compiler plugin knew that it had to use Java 11.

0

There are 0 best solutions below