https://kotlinlang.org logo
Title
j

jeff

02/01/2022, 8:07 PM
KSP quickstart says to add
"build/generated/ksp/*main*/kotlin"
to your sourceSets. However I have a multiplatform project and the generated files are put in different folders depending on what target I'm building, e.g.
"build/generated/ksp/*jvmMain*/kotlin"
or
"build/generated/ksp/*jsMain*/kotlin"
. This is despite the fact that the actual code being processed is in
commonMain
. Therefore, I don't know how I can make my code in
commonMain
depend on generated code. Has anyone run into this?
my build.gradle.kts (abridged)
plugins {
    kotlin("multiplatform") version "1.6.10"
    kotlin("plugin.serialization") version "1.6.10"
    id("com.google.devtools.ksp") version "1.6.10-1.0.2"
    application
}

repositories {
    mavenCentral()
}

val arrowVersion = "1.0.3-alpha.1"

kotlin {
    jvm {

    }
    js(IR) {

    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
                implementation("io.arrow-kt:arrow-core:$arrowVersion")
                implementation("io.arrow-kt:arrow-optics:$arrowVersion")
                configurations["ksp"].dependencies.add(project.dependencies.create("io.arrow-kt:arrow-optics-ksp-plugin:$arrowVersion"))
            }
        }
        val commonTest by getting {
            dependencies {
            }
        }
        val jvmMain by getting {
            dependencies {
            }
        }
        val jvmTest by getting
        val jsMain by getting {
            dependencies {
            }
        }
        val jsTest by getting
    }
}
e

evant

02/01/2022, 8:19 PM
Yeah that will add the task to all configurations. If you just want common you can use https://github.com/google/ksp/issues/567#issuecomment-955035157
j

jeff

02/01/2022, 8:26 PM
Yessss that worked perfectly, thank you! Slightly gross but not nearly as gross as what I was going to do otherwise 🙂