Hello everyone. I'm a total Kotlin, and Java, noob...
# ktor
j
Hello everyone. I'm a total Kotlin, and Java, noob so if my question is embarrassing, I'm sorry. But... I started a new Ktor project and included routing and compression plugins. I wanted to be able to serialize my models for output in my routes, so following the pattern in https://ktor.io/docs/creating-http-apis.html#dependencies I added the serialization plugin (https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.serialization) to the
build.gradle.kts
file. When I do that, the
./gradlew build
goes from passing, to failing with
Copy code
Could not determine the dependencies of task ':distTar'.
> Could not resolve all dependencies for configuration ':runtimeClasspath'.
   > Could not create task ':compileKotlin'.
      > Could not create task of type 'KotlinCompile'.
         > Could not create an instance of type org.jetbrains.kotlin.gradle.tasks.KotlinJavaToolchainProvider.
            > Could not generate a decorated class for type KotlinJavaToolchainProvider.
               > Cannot have abstract method KotlinJavaToolchain.getJdk().
Totally flummoxed me, and my google-fu has failed me. Can anyone point me in the right direction please?
a
please paste your build.gradle.kts file here
j
Copy code
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project

plugins {
    id("org.jetbrains.kotlin.plugin.serialization") version "1.5.30-M1"
    application
    kotlin("jvm") version "1.5.21"
}

group = "com.trackity"
version = "0.0.1"
application {
    mainClass.set("com.trackity.ApplicationKt")
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("io.ktor:ktor-server-core:$ktor_version")
    implementation("io.ktor:ktor-server-netty:$ktor_version")
    implementation("ch.qos.logback:logback-classic:$logback_version")
    testImplementation("io.ktor:ktor-server-tests:$ktor_version")
    testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlin_version")
}
I do need to figure Gradle out I think. Every time I try and change it based on what it seems like the docs suggest, it breaks 😞
a
try matching kotlin version and serialization plugin version also, please apply your plugins in this order
Copy code
plugins {
  kotlin("jvm") version "1.5.21"
  kotlin("plugin.serialization") version "1.5.21"
  application
}
j
Awesome! Thanks - that works. The version was the key - the ordering didn't seem to make a difference (I tried both ways). Do these versions follow semver? I'd assumed 1.5.30 would be compatible with anything up to 2.x.x
a
the versions depends on the kotlin compiler plugin which is currently not stable. So just make sure kotlin version and serialization version are the same for the time being. Until the compiler API is stable.
j
Thanks again - I really appreciate you taking the time to help me out. Loving the language, but coming from a Python/Javascript/PHP world, the surrounding ecosystem is the challenge.
a
You're very welcome to the community . . . We are a warm community after all
🙌 1