Stop using sourceCompatibility and targetCompatibility

And start using --release. As of JEP-247 released in java 9, the flag will allow you to compile for older releases of java without worrying about the dreaded NoSuchMethodError.

Stop talking and show me the code!

Gradle

tasks.withType(JavaCompile) {
    options.release = 8
}

Enter fullscreen mode Exit fullscreen mode

Gradle (kts)

tasks.withType<JavaCompile> {
    options.release.set(8)
}

Enter fullscreen mode Exit fullscreen mode

Maven (xml)

<configuration>
    <release>8</release>
</configuration>

Enter fullscreen mode Exit fullscreen mode

原文链接:Stop using sourceCompatibility and targetCompatibility

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容