Hi, here is the latest KSP release: <1.5.21-1.0.0-...
# ksp
j
Hi, here is the latest KSP release: 1.5.21-1.0.0-beta07 Highlights • starting this release, KSP binary has moved from gMaven to MavenCentral repo. • Kotlin native is now supported. • ksp.incremental.intermodule is enabled by default Issues resolved #60 Using KSP with Kotlin Multiplatform #411 Publish artifacts to be used with kotlinc command line #490 KspTask does not support gradle remote cache #240 java.lang.IllegalStateException: Cannot find descriptor for values #439 NPE #518 Configuration on demand does not work with KSP #540 Publish KSP on Maven Central? Please give it a try and let us know any thoughts!
🎉 17
n
Great to see multiplatform support! Is it now possible to apply KSP selectively on certain targets in a multiplatform project, or is there only a global
ksp
configuration?
t
It's only a global
ksp
for now.
n
Thanks! Are
androidNative*
targets expected to be working in this release? I'm getting:
org.gradle.api.InvalidUserDataException: Cannot change dependencies of dependency configuration ':sample:kotlinCompilerPluginClasspathAndroidNativeX64Main' after it has been resolved.
in the simplest possible setup (empty project, just a single androidNativeX64() target and a no-op ksp processor). I can file a bug if this is not expected
t
Thanks for discovering this. A bug report with a repro case would be very appreciated 🙂
I tried adding androidNative{X64, Arm64} and it works for me. Could you post your build.gradle.kts and stack trace?
I probably know what happened but haven't been able to come up with a test case yet: https://github.com/ting-yuan/ksp/commit/71b8e918a50d351315b6c0dbdebce332005d45ee would really appreciate if you can share how to produce it.
n
Just filed this with attached repro project: https://github.com/google/ksp/issues/566 thanks a lot for looking into this. Also if you can think of any workaround that I can use while you look for a proper solution, I'd appreciate it!
t
Thanks, the stack trace indicates the issue which is addressed in the tentative commit above. However, I'm still not able to reproduce it locally even with freshly cloned project that you provided. May I know your build command line and environment (OS, gradle properties, etc)? I tried on a Debian testing with
./gradlew assemble
but no luck. My guess is that there could be something that causes the configuration to be evaluated before KSP (inappropriately) modifies it. Maybe cleaning up ~/.gradle/gradle.properties could work this bug around.
n
@Ting-Yuan Huang you're right, command line works just fine. I get the error during Android Studio sync, whatever that means in gradle world. To reproduce, I just do a clean pull and open the project in AS (Arctic Fox | 2020.3.1, macOS 11.2). It will run the first sync and fail, error pops up in the
Build
tab. File > "Sync project with Gradle files" will also trigger it again.
t
I can reproduce with AS and verified that it's fixed in the above commit. Thanks!
👍 1
a
Hello, I was wondering, since K/N support was added, and K/N compiler and K/JS(IR), are all IR based, I assumed that ksp would work well with K/JS as well. Is that the case? I am currently getting a
Copy code
> Failed to calculate the value of task ':compileTestDevelopmentExecutableKotlinJs' property 'entryModule$kotlin_gradle_plugin'.
   > Collection has more than one element.
Just by including the ksp plugin on and attempting to build the module via gradle. Removing either the js target or the ksp plugin solves the problem. Asking to check if this is has already been covered or not. So that I know if K/JS is supported then perhaps my gradle configuration is wrong [UPDATE]: Removing just the processor dependency
Copy code
dependencies {
//  ksp(project(":test-processor"))
}
Makes the build pass, even with the ksp plugin (So, I am assuming it is not the ksp gradle plugin here)
t
Can you share your build.gradle[.kts]? On the other hand, does JS non-IR work?
a
Copy code
plugins {
    id("com.google.devtools.ksp")
    kotlin("multiplatform")
    kotlin("plugin.serialization")
}

kotlin {
    jvm()
    js(IR) { browser(); nodejs() }
    ios()
    linuxX64()

    sourceSets {
        val commonMain by getting {
            dependencies {
                api(kotlinx("serialization-core", vers.kotlinx.serialization))
                api(project(":annotations-core")) // separate modules for annotations
            }
        }

        val jvmMain by getting {
            val ksp by configurations
            dependencies {
                ksp.dependencies.add(project(":annotations-processor"))
            }
        }
    }
}

// dependencies {
//    ksp(project(":annotations-processor"))
// }
Also tried putting the ksp configuration in
commonMain
I end up still getting the same error. Non IR (LEGACY) fails with
Copy code
> Task :processDceJsKotlinJs FAILED
error: at /media/andylamax/workspace/PiCortex/bitframe/build/js/packages/bitframe-bitframe-core/kotlin/bitframe-bitframe-core.js (804, 26): missing name after . operator
t
Sorry, I forgot that KSP + JSIR needs a patch that isn't available before Kotlin 1.6.0. We should have detected that in current release and printed an useful message. (I was confused, too) As of the legacy JS compiler, I can't immediately see why
processDceJsKotlinJs
fails. Can you check the outputs of processors (
kspKotlinJs
) and compiler (
compileKotlinJs
) to find out which step might go wrong?
a
So for
LEGACY
, the tasks
kspKotlinJs
and
compileKotlinJs
do succeed, but
processDceJsKotlinJs
fails. Should I create a ticket for this + JS IR?
t
Yes, please. Let's move the discussion in the issue/bug. I'm wondering how the generated files by
kspKotlinJs
and
compileKotlinJs
look. Are they good, or anything suspicious?