Move to OpenJDK-11 but compile in Java 8

╄→尐↘猪︶ㄣ 提交于 2019-11-29 10:36:06

I'd say :

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

Because the default value of sourceCompatibility is the version of the current JVM in use.

source : https://docs.gradle.org/current/userguide/java_plugin.html

you need to set the sourceCompatibility too.

See this post here Gradle, "sourceCompatibility" vs "targetCompatibility"?

As of Java 9 you can use the --release N option to cross-compile with Gradle. Setting the sourceCompatibility and targetCompatibility is not enough because in that case you need to set the bootClasspath to JDK N too. See What is the --release flag in the Java 9 compiler? for more details.

Instead, use the Java 9+ "--release" compilerArg like this:

compilerArgs.addAll(['--release', '8'])

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.CompileOptions.html

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