Not sure where to put this, I updated to Kotlin 1....
# gradle
m
Not sure where to put this, I updated to Kotlin 1.5.30 and got hit by:
Copy code
'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
Except that I don't have any java source in this project. Can I disable the javaCompile task somehow?
e
It can be skipped with:
Copy code
tasks.withType<JavaCompile> {
  onlyIf { false }
}
m
I thought about that but I wouldn't expect that to silence the warning. Let me check
e
Yeah, from the message it seems like some task consistency check is going on, not an error from the task per se. But anyway, worth trying...
m
Yep, same warning
I can set
targetCompatibility = 1.8
in my gradle script but that feels kind of misleading since there's no java to be found
e
Or set the Kotlin target to 11, if that's not a problem for you
m
It's for a lib so the more compatibility the better
v
Maybe set the Java toolchain? The Kotlin plugin should fully support it now afair and then it should also match. btw.
enabled = false
over
onlyIf { false }
:-)
👍 2
💯 1
e
Cool, didn't know about
enabled
d
just hit the same thing with
1.5.30
(multi module pure kotlin project)... I'm using SDKMAN and got both Java 8 and 11 (default) installed locally - when I set the toolchain version to Java 8 kapt blew up (when processing spring annotation) unable to find
java.lang
packages - without toolchain config it run fine just with the warning above. Might be unrelated but my test android (using Android tools 7.0.1) build also blew up on version update (without setting java toolchain) with
Cannot have abstract method KotlinJavaToolchain.getJdk()
- works fine with
1.5.21
*and yeah it looks like it is not a Gradle issue
t
The warning comes from Kotlin plugin. Best solution would be to set toolchain, but you could also disable this check by adding
kotlin.jvm.target.validation.mode=ignore
into
gradle.properties
m
My point is that it's a project that doesn't use java at all
Ideally I'd like the Kotlin Plugin to not warn me about Java if there's no Java being compiled
t
yes, there is a bug that KGP creates java tasks as well when no java sources are available. Let me find it
👀 1
👍 1
Sorry for the delay - here the bug issue: https://youtrack.jetbrains.com/issue/KT-48745
there is a bug that KGP creates java tasks as well when no java sources are available.
Actually KGP apply
java-library
plugin, but should not trigger creation of registered Java tasks when Java sourceset is empty
❤️ 1
🙏 1