“maven.compiler.release” as an replacement for source and target?

夙愿已清 提交于 2020-08-26 07:07:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!