问题
I have two questions about maven.compiler.release
-tag
I want to replace
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
to
<properties>
<maven.compiler.release>1.12</maven.compiler.release>
</properties>
If I use <maven.compiler.release>
-property, do I have to set the release tag also in the plugin?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<!-- do I need that ? -->
<release>12</release>
</configuration>
</plugin>
According to https://www.baeldung.com/maven-java-version, it is set to both.
If I use maven.compiler.release
instead of maven.compiler.source
and maven.compiler.target
, then -bootclasspath
is also set and will do a cross-compile. What does this mean? Will the compilation file sizes with set -bootclasspath
be bigger or will the compilation need more time?
回答1:
Simply the property <maven.compiler.release>12</maven.compiler.release>
is sufficient. And you don't need to set also the configuration for maven-compiler-plugin. The configuration for release tag is automatically picked up.
The bootclasspath part is automatically done by using the --release
option. The size of files is not related to that...
So simple suggestions use release
part for JDK9+ otherwise source/target...
来源:https://stackoverflow.com/questions/59049980/maven-compiler-release-as-an-replacement-for-source-and-target