I'm looking at this issue on the gradle issue trac...
# announcements
t
I'm looking at this issue on the gradle issue tracker (https://github.com/gradle/gradle/issues/2510), and the tl;dr is there's an issue with using -target and -source, and you can tell javac to use
--release 8
directly. My question is, with a Kotlin-only project, is there a way to tell it that in a gradle build script? I looked in
KotlinJvmOptions
and all its super classes, and didn't see any likely suspects. I tried passing it to
freeCompilerArgs
, but that complains its an unknown value.
d
For Kotlin, you’re looking for
kotlinOptions.jvmTarget
on the compile task
t
ok. I am setting that, but it's unclear how it gets implemented (release vs target/source)
does
kotlinOptions.jvmTarget
use
-target/-source
or
--release
when writing java bytecode?
f
These options have no meaning for kotlinc as it produces its own bytecode with its own internal mechanisms. Setting
jvmTarget
to
8
will produce bytecode that is compatible with any JVM release that can interpret it, that's it.
t
ok, thanks
i
If you want to build kotlin code so that it can run on specific JDK version, you should also specify path to that JDK in
kotlinOptions.jdkHome
parameter in addition to
jvmTarget
. This will ensure that you don't accidentaly use any API from a newer JDK.
t
I'll give that a try, thanks! I'm running into an issue where I'm trying to build with JDK 14 but run some tests on lower JDKs (because only Gradle 6.3 supports 14, and I test against lower gradle versions for my gradle plugin)
my project is entirely kotlin, with some tests written in groovy (spock tests)
unfortunately tests still fail. Something else is going on. I've raised it with gradle