https://kotlinlang.org logo
Join Slack
Powered by
# ksp
  • e

    eygraber

    03/12/2025, 4:47 AM
    If I wanted to "unwrap" a value class would I just look at the type of the first constructor property?
    j
    • 2
    • 4
  • r

    Remi Latapy

    03/14/2025, 3:35 PM
    👋 Is it conceivable to use KSP to generate lint rules ? I would like to create an annotation like
    @Replacing("androidx.compose.material3")
    to enforce design system use in Compose. I don't see how to do it in pure Lint rule
    e
    w
    d
    • 4
    • 5
  • j

    jbarr

    03/19/2025, 9:12 PM
    any reason there isn't an
    artifacts.zip
    for 2.1.10-1.0.31? bazel's rules_kotlin uses these for compilation
    t
    • 2
    • 2
  • e

    eygraber

    03/20/2025, 4:25 PM
    Is a release planned for 2.1.20 today, or will it come later?
    👀 3
    j
    z
    • 3
    • 5
  • z

    Zach G

    03/31/2025, 1:22 PM
    Is the Visitor pattern still considered the best approach for processing multiple separate annotations to build one or more files?
    d
    • 2
    • 1
  • r

    RTAkland

    04/01/2025, 2:54 PM
    hi, I want to use ksp to generate new code, but I dont want to generate a new file, just add the code into the generated class file, I google it, but the result says I should use asm to do this, Is this correct?
    h
    a
    • 3
    • 2
  • r

    RTAkland

    04/03/2025, 11:38 AM
    Hi, I want to use kcp to insert a new function to a class, how?, is there a example?
    e
    • 2
    • 6
  • n

    Nitesh Singh

    04/04/2025, 11:25 AM
    hey there, I am getting error how i will fix that issue ?
    g
    • 2
    • 2
  • n

    Nitesh Singh

    04/04/2025, 11:25 AM
    image.png
  • f

    Forrest Pangborn

    04/10/2025, 1:32 PM
    I have a processor that creates KotlinPoet
    TypeName
    instances from
    KType
    values, using the
    asTypeName()
    extension to
    KType
    provided by KotlinPoet. Looks like the implementation of
    asTypeName()
    relies on
    kotlin-reflect
    (the
    typeParameters
    property on
    KClass
    ). In KSP1, using
    asTypeName()
    like this works but with KSP2 I’m getting an exception:
    Copy code
    Caused by: kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
        at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:88)
        at kotlin.jvm.internal.ClassReference.getTypeParameters(ClassReference.kt:38)
        at com.squareup.kotlinpoet.ParameterizedTypeName$Companion.get$kotlinpoet(ParameterizedTypeName.kt:236)
        at com.squareup.kotlinpoet.ParameterizedTypeNames.asTypeName(ParameterizedTypeName.kt:275)
    My processor already includes
    kotlin-reflect
    as an implementation dependency – and I've tried adding it for the consumer of the processor too, but same failure. Running with latest KSP version but in legacy mode (via
    useKsp2 = false
    ) works fine as well – so seems definitely an issue with KSP2. Anyone have any suggestions on other things I can try?
    s
    • 2
    • 1
  • t

    Tomáš Procházka

    04/14/2025, 10:35 AM
    Hi. Is there please any way how to get more detail performance statistics from KSP? In our project KSP take more than kotlin compilation, we are using room, dagger, anvil and some custom KSP plugin. I would like to know which KSP plugin took how much time, it will be somehow shared, right? But it is there a way how to somehow find which plugin is the bottleneck? I care mainly about incremental IDE build, where change in one class cause 25s KSP task and only 2s kotlin compilation. I would like to found what causing that 25s delay after just one class change.
    👀 1
    t
    t
    t
    • 4
    • 9
  • t

    trevjones

    04/14/2025, 9:23 PM
    Ting-Yuan you alluded to a better solution being more possible end of year here? Just trying to track down all my loose ends for turning on
    useKSP2
    and found you had given them a nudge on what appears to be my last blocker now. Any chance there is a more stable API we can ask the moshi maint team to look at now?
    t
    • 2
    • 2
  • d

    Denis Stepanov

    04/23/2025, 1:08 PM
    @Ting-Yuan Huang It looks like your last commits broke Micronaut Framework integration https://github.com/google/ksp/commit/498cbe60c132fb355dc36cc7ac6c8d7da229671a I have almost finished figuring out all the changes in KSP2 and the last snapshot change completly broke annotation reading. Cannot properly tell was is missing. I had to build a local snapshot to finish the work. Can you please investigate what can be wrong?
    t
    • 2
    • 1
  • a

    Aru Jeganathan

    04/24/2025, 5:56 PM
    I have a maven project in my company and we're using Kotlin 1.9 with kapt. I wanna migrate to kotlin 2.x. Is there a way I can migrate from kapt to ksp with maven?
  • o

    Olivier Notteghem

    04/28/2025, 11:39 PM
    Could someone tell me how to get traction on https://github.com/google/ksp/issues/1385 ? This bug affects most bazel + rules_kotlin users and introduces a bad performance bottleneck. Thanks in advance.
    t
    • 2
    • 8
  • j

    Jake Woods

    05/01/2025, 12:33 AM
    Is there a way to get the return type of a generic constructor in ksp2 that preserves the type parameters? I have a class like this:
    Copy code
    sealed class KonvertResult<out T, out E> {
      data class Ok<out T>(val value: T) : KonvertResult<T, Nothing>()
      data class Err<out E>(val error: E) : KonvertResult<Nothing, E>()
    }
    I'm getting a reference to it's constructor in ksp like this:
    Copy code
    private val okConstructor = resolver
        .getClassDeclarationByName<KonvertResult.Ok<*>>()
        ?.getConstructors()
        ?.firstOrNull()
    In ksp1 when I run
    okConstructor.returnType
    I get
    Ok<T>
    . But in ksp2 when I return
    okConstructor.returnType
    I get
    Ok<*>
    . Is there any way I can get back to
    Ok<T>
    ?
  • z

    Zac Sweers

    05/07/2025, 8:01 PM
    wanted to nudge this issue - https://github.com/google/ksp/issues/1789#issuecomment-2860100164 With AGP 8.10.0, we're more or less not able to apply the KSP plugin on-demand with our convention plugin anymore due to its odd interaction with AGP's lifecycle
    👀 1
    t
    • 2
    • 4
  • j

    JP Sugarbroad

    05/08/2025, 7:50 PM
    Anyone run into an issue where ksp generates classes with incorrect name mangling? (2.0.21 was fine, 2.1.20 is broken)
    • 1
    • 1
  • d

    David Herman

    05/13/2025, 9:53 PM
    I just tested updating our project from using KSP 2.1.20-1.0.32 to 2.1.20-2.0.0, and I'm getting crashes in my KSP processors around resolving annotation arguments. More details in the thread 🧵
    t
    • 2
    • 12
  • b

    baxter

    05/21/2025, 8:30 PM
    I got a weird situation on an Android app. I have a build as such: •
    library
    depends on
    feature
    •
    library
    also depends on a custom ksp processor The problem I'm running into is that when I make a change in the
    strings.xml
    file in
    feature
    , the first run generates the source files fine from my ksp processor, but the second run fails due to the generated files being deleted and not generated. It seems to be an issue with incremental builds, because turning incremental off will cause everything to generate just fine. More in 🧵:
    j
    • 2
    • 4
  • e

    Edoardo Luppi

    05/28/2025, 12:10 PM
    If there is a topic that's still not entirely clear to me, is how errors should be reported. Let's say that my processor encounters a symbol that it cannot process for whatever reason: should I throw a specific exception, use
    KSLogger.error
    while returning an empty list, or should I prefer a "never error out" approach?
    t
    • 2
    • 4
  • h

    Hamza GATTAL

    05/30/2025, 3:04 PM
    Will KSP be moved to the Kotlin repository?
    h
    • 2
    • 1
  • j

    jamireh

    06/05/2025, 3:57 PM
    👋 We have a build logic plugin that has a
    compileOnly
    dependency on
    com.google.devtools.ksp:symbol-processing-aa
    so that we can invoke KSP manually (for classpath isolation reasons) but we're finding we can't upgrade to
    2.1.21-2.0.1
    and are stuck on
    2.1.20-1.0.31
    because the binary version of the former is
    2.2.0
    , which is still in RC. Our project uses Gradle 8.13 but even on 8.14.1, we can't seem to compile against this new version, presumably because the embedded Kotlin version is still on
    2.0.0
    Given the KSP version implies compatibility with
    2.1.21
    , why is the binary version
    2.2.0
    ? Is this is a mistake or do we just need to wait for a version of Gradle that embeds at least 2.1.x?
  • m

    Maya

    06/10/2025, 10:53 PM
    Hi all - KSP version 2.0.2 was released yesterday and includes the following changes and bug fixes: • KSP1: use new mangling scheme for inline classes • KSP task (non-)registration happens too soon • [ksp2] Resolver.getJvmName wrong for properties that start with is • Inlined JVM name is not correct • [KSP2] Annotation values of inner annotations shouldn't be marked as default • Properly support @all annotation use site target To view all released versions of KSP, visit https://github.com/google/ksp/releases. Thanks! The KSP Team
    🎉 7
    j
    • 2
    • 4
  • p

    pablisco

    06/11/2025, 11:03 PM
    Hopefully this is the right place to ask. I was wondering if it's possible to generate source code for a kts script. I wanna try to use custom script runners, but I was wondering if there's something available for plain kts. It would be interesting to have something like plugins if nothing like that exists.
    g
    r
    • 3
    • 5
  • e

    eygraber

    06/23/2025, 6:32 PM
    Will the 2.2.0 release of KSP bump the language version? I'm getting the following errors (technically warnings, but I have
    -Werror
    specified and it isn't yet possible to suppress this one)
    Copy code
    w: Language version 1.9 is deprecated and its support will be removed in a future version of Kotlin
    e: warnings found and -Werror specified
    t
    r
    • 3
    • 6
  • s

    Seokjae Lee

    06/24/2025, 8:54 AM
    Hello team 👋 I don’t know if this is something I should be talking about in this channel, I’ve made a simple open source using KSP. I’m sure there’s a lot of room for improvement, but feedback is always welcome. Have a great day 🙂
  • a

    Anton Saatze

    06/27/2025, 12:56 PM
    Hi K folks. 📣 I just released my very first open source project and I am happy to get some feedback in case anyone is interested. This is a KSP plantuml generator, which converts your codebase into a plantuml class diagram, that you can render yourself. 🔧 There are plenty of configuration options. internet problems Thanks to the Kotlin symbol processor, all of this happens locally and since only the raw plantuml file is generated. None of your project information are shared with any online service. 🔐 This should guarantee, that you can also use this KSP-library within your companies projects as well without being afraid that your confidential sourcecode is shared. 💼 I am happy to get feedback and improvement suggestions as a direct message.
    👍 5
  • v

    viluon

    06/27/2025, 5:18 PM
    Hi, I'd like to attract some contributor attention to a pull request I opened last week. The idea is to get KSP to report more precise source location information for better diagnostics. I'd appreciate some discussion on the API evolution topics I mentioned, i.e. whether breaking changes should be introduced and whether the primary source location info should be based on
    startOffset
    or on
    textOffset
    . All feedback is welcome! So far no one approved even running the CI on this one 😅
  • p

    Pratik Sahu

    07/02/2025, 4:53 PM
    Hi, we recently upgrade to K2 and also moved from kapt to ksp for dagger. Even with a one line change as simple as adding a
    Log
    , both the
    kaptKotlin
    and
    kspKotlin
    are running which takes around 2 mins. When I compared this with before all the changes the build is almost instant