Usage with JVM 11
nicofari opened this issue · comments
During task kspKotlin I get this warning:
Task :kspKotlin
'compileJava' task (current target is 11) and 'kspKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
By default will become an error since Gradle 8.0+! Read more: https://kotl.in/gradle/jvm/target-validation
Should I put version 11 in ksp plugin version? something like "id "com.google.devtools.ksp" version "11" ?
what that version refers to? it seems jdk 1.8 but shouldn't it be the plugin version?
thanks a lot
This is my complete build.gradle:
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "org.jetbrains.kotlin.jvm" version "${kotlinVersion}"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.google.devtools.ksp" version "1.8.10-1.0.9"
}
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "java"
repositories {
mavenCentral()
}
compileKotlin.kotlinOptions.jvmTarget = "11"
compileTestKotlin.kotlinOptions.jvmTarget = "11"
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
test {
useJUnitPlatform()
testLogging.showStandardStreams = true
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}"
implementation platform("org.http4k:http4k-bom:${http4kVersion}")
implementation "org.http4k:http4k-core"
implementation "org.http4k:http4k-serverless-lambda"
implementation "org.http4k:http4k-cloudnative"
implementation "org.http4k:http4k-contract"
implementation("org.http4k:http4k-format-moshi") {
exclude group: "org.jetbrains.kotlin", module: "kotlin-reflect"
}
implementation("se.ansman.kotshi:api:$kotshiVersion")
ksp("se.ansman.kotshi:compiler:$kotshiVersion")
implementation "org.http4k:http4k-opentelemetry:${http4kVersion}"
implementation "org.apache.pdfbox:pdfbox:2.0.27"
implementation "de.redsix:pdfcompare:1.1.61"
implementation "net.sf.barcode4j:barcode4j:2.1"
testImplementation platform("org.junit:junit-bom:${junitVersion}")
testImplementation "org.http4k:http4k-testing-hamkrest"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-engine"
}
shadowJar {
manifest.attributes['Main-Class'] = 'it.multidialogo.multiprinter.MultiprinterKt'
archiveBaseName.set("multiprinter")
archiveClassifier.set(null)
archiveVersion.set(null)
mergeServiceFiles()
}
task buildZip(type: Zip) {
from compileKotlin
from processResources
into('lib') {
from configurations.compileClasspath
}
}
This is not an issue with Kotshi. Please refer to the link that was included in the error message: https://kotl.in/gradle/jvm/target-validation
It was a question: <<which version should I put in, to use java 11 with kotshi plugin>>
thanks anyway
Ah, sorry. No, you're getting this error because some compile tasks uses Java 8 and some uses Java 11.
I would recommend looking into toolchains which solves this: https://docs.gradle.org/current/userguide/toolchains.html