https://kotlinlang.org logo
Join Slack
Powered by
# ksp
  • 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
    m
    • 4
    • 14
  • 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
    d
    • 2
    • 1
  • 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
    m
    • 2
    • 1
  • r

    Rafael Diaz

    07/05/2025, 6:54 PM
    Hi! I just released KReplica, a code generation tool that seeks to make it easier to manage multiple DTO variants from a single interface: a base DTO, a create request DTO, and a patch request DTO. It can also optionally automatically create value classes and versioned schemas. That said, I think the most useful feature of KReplica is how it generates sealed interfaces. Allowing you to use exhaustive
    when
    statements to filter through all schema types, filtering by a specific schema version, or filtering by a specific schema variant (e.g. base DTOs). There's a Readme with more info. I hope someone could comment if the project seems interesting and/or if the README is understandable. There's a lot of examples, but just the first two examples are important to understanding it. https://github.com/AvaileDev/KReplica
    👍 1
  • r

    Rafael Diaz

    07/07/2025, 5:25 PM
    Hi again! Unfortunately it doesn't let me edit my previous message (I believe it's too old to edit), but I do wish to add an example. KReplica allows you to specify what variants you want to create, and which properties should be included in which variants (via include/exclude). _ KReplica also supports unversioned DTOs, but say you want a versioned one; And this is version 1 of User Account. Note that typically I want the ID to be created by the database, so I want to exclude it from being patched/created on the Kotlin side.
    Copy code
    @Replicate.Model(variants = [DtoVariant.DATA, DtoVariant.PATCH, DtoVariant.CREATE])
    private interface V1 : UserAccount {
        val name: Pair<String, String> // this is included in all the variants
        @Replicate.Property(include = [DtoVariant.DATA])
        val id: Int
        @Replicate.Property(exclude = [DtoVariant.CREATE])
        val banReason: String?
    }
    Now say you have Version 2 of User Account (notice we have nominal typing turned on which is another feature):
    Copy code
    @OptIn(ExperimentalUuidApi::class)
    @Replicate.Model(
        variants = [DtoVariant.DATA, DtoVariant.PATCH],
        nominalTyping = NominalTyping.ENABLED
    )
    private interface V2 : UserAccount {
        val firstName: String
        val lastName: String
        @Replicate.Property(include = [DtoVariant.DATA], nominalTyping = NominalTyping.DISABLED)
        val id: Uuid
    }
    I will continue the rest in a thread so this message doesn't get too long.
    • 1
    • 3
  • b

    Bernd Prünster

    07/11/2025, 9:04 AM
    maybe a dummy question but how fast is KSP usually to publish a version compatible with a Kotlin EAP? I'd like to test my project, but it relies on KSP Thread in Slack Conversation
  • a

    Anton Saatze

    07/21/2025, 9:01 PM
    👋 Does anyone know how I can find out whether my KSFunctionDeclaration of my class is inherited by a parent super type or if the function is declared in this class. For my project Ksp-plantuml I want to ignore functions and properties from a class, if they are declared in a superType. Not that I cannot come up with my own solution for this, but I am sure swarm intelligence finds the best solution for this 😅
  • s

    Shivam Verma

    07/24/2025, 9:25 AM
    Hi folks 👋 For an android project, I am trying to read an annotation in the main source set and then generate some test code in the androidTest source set. Here's what I have so far: 1. If I apply
    ksp(:processor)
    , the code is generated in
    /build/generated/ksp/debug/
    but then the generated code is not able to resolve the androidTest dependencies. 2. If I apply
    kspAndroidTest(:processor)
    , my processor is not able to find the annotations in the main source set. Any tips ?
    m
    • 2
    • 8
  • a

    Anton Saatze

    07/24/2025, 4:29 PM
    Why does the
    componentN()
    function of data classes have modifier override but has no SuperClass with the same function? Does anybody know ?
    j
    • 2
    • 3
  • s

    Sha Sha Chu

    07/24/2025, 6:05 PM
    hi all, we have had an intermittent issue to do with multiple round processing and I'm looking for tips to debug. We use Hilt, and we sometimes inject classes which are generated from an internal ksp processor. every so often, Hilt fails to find the generated class, and I don't know whether it's a bug in Hilt with not correctly deferring the type, a bug in ksp where it's incorrectly reaching the terminal condition, or our processor where it may sometimes fail to run. any suggestions?
    y
    d
    • 3
    • 4
  • a

    alexey.andreev

    07/30/2025, 6:22 AM
    Is it possible to read/depend on non-Kotlin files? E.g.
    properties
    files in
    src/main/resources
    ?
    h
    • 2
    • 1
  • s

    sindrenm

    07/31/2025, 8:00 AM
    Time for a 2.2.20-Beta2-2.0.2 release? 🙏
    z
    • 2
    • 3
  • r

    ritesh

    08/01/2025, 5:29 AM
    Do we need support from epoxy before migrating the project to k-2.2.20? More in thread
    ✅ 1
    • 1
    • 3
  • a

    Alexander Ioffe

    08/04/2025, 4:07 AM
    Question on the KSP documentation here. The documentation seems to indicate that if you want KSP processing to be done in a KMP project on (for example) both commonMain and jvmMain you use the following configuration:
    Copy code
    kotlin {
        jvm()
        ...
        sourceSets {
            val commonMain by getting { ... }
            val jvmMain by getting { ... }
        }
    }
    
    dependencies {
        add("kspCommonMainMetadata", project(":my-processor"))
        add("kspJvm", project(":my-processor"))
    }
    In practice however, this seems to blow up my build by generating the same code in commonMain twice! The first time in
    MyProject/build/generated/ksp/metadata/commonMain/kotlin
    and the second in
    MyProject/build/generated/ksp/jvm/jvmMain/kotlin
    . Now to be fair, if I have some class in jvmMain it will only appear in the latter location but why is everything from the commonMain directory also there???
  • h

    Hakan Mehmed

    08/04/2025, 8:36 PM
    Hi everyone, I am reposting here what is already in ksp github page readme as of today:
    Copy code
    Deprecation notice for KSP1
    KSP1 is deprecated and support will be removed. We are focusing our development efforts on KSP2 to provide better performance, improved APIs, and a more robust architecture for the future.
    
    Compatibility Limitations
    Please be aware that KSP1 will not be updated to support upcoming major versions of the Android and Kotlin toolchains. Specifically, KSP1 will not be compatible with:
    
    Kotlin version 2.3.0 and higher.
    Android Gradle Plugin (AGP) version 9.0 and higher.
    Projects using KSP1 may not behave correctly (or fail the build) if you upgrade to these or any subsequent versions of AGP or Kotlin.
    
    To ensure your annotation processors continue to function correctly and to take advantage of future tooling advancements, it is crucial to migrate your projects to use KSP2 (which has been the default since beginning of 2025)
    Support for KSP1 is expected to be removed by end of 2025 (possibly even earlier) If there are any bugs in KSP2 that are total blockers for the migration to it, please let us know
    👍 1
    e
    g
    +2
    • 5
    • 6
  • s

    scana

    08/05/2025, 6:02 PM
    Has anyone seen an issue like the following with Kotlin 2.2 / KSP 2.2.0-2.0.2? / KSP2 enabled?
    Copy code
    > A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
       > Error while resolving ksp.org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl 
         from RAW_FIR to STATUS
         current declaration phase STATUS
         origin: Source
         session: class ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSourcesSession (Kotlin reflection is not available)
         module data: class ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.projectStructure.LLFirModuleData (Kotlin reflection is not available)
         KaModule: class ksp.org.jetbrains.kotlin.analysis.project.structure.impl.KaSourceModuleImpl (Kotlin reflection is not available)
         platform: JVM (21)
    • 1
    • 2
  • s

    Sandeep Dhami

    08/06/2025, 12:07 PM
    Hey everyone, I’m facing an issue where KSP fails to resolve types in Kotlin Multiplatform (Android/iOS) targets when using kotlin-inject 0.8.0. The types are declared in commonMain, but during iOS compilation (kspKotlinIosSimulatorArm64), KSP throws unresolved type errors like:
    Copy code
    Error type '<ERROR TYPE: PlatformResourcesWrapper>' is not resolvable in the current round of processing.
    I’ve detailed the problem and shared a code snippet in this GitHub issue: 🔗 https://github.com/evant/kotlin-inject/issues/499 Would appreciate any guidance or workaround suggestions 🙏! CC @evant @eygraber
  • m

    micah

    08/06/2025, 5:55 PM
    Hey, everyone. I'm pretty new to KSP, but I've got a simple project up and running, and now I'm looking at testing. I think I've got a few questions: 1. Is https://github.com/tschuchortdev/kotlin-compile-testing still the goto solution to simplify testing? It's referenced in the development docs, but I don't actually see it getting used in the major ksp projects. 2. Does the advent of KSP2 have implications for testing? Is there an easier way now that KSP2 is available? Practically speaking, I don't need full end to end testing, but need enough KSP magic to go from some annotated classes to `KSClassDeclaration`s.
  • r

    rnett

    08/09/2025, 5:50 AM
    Hey there, in the documentation of
    KSValueArgument.value
    , it states that it may be a
    KSClassDeclaration for annotation arguments of type Enum (in this caseKSClassDeclaration.classKind equals to ClassKind.ENUM_CLASS);
    . However,
    ClassKind.ENUM_CLASS
    is used for the enclosing
    enum class
    . If this is accurate, how can you determine the entry that is the actual value of the argument? Or is the documentation just mistaken and it's actually
    ClassKind.ENUM_ENTRY
    ?
  • z

    Zach G

    08/13/2025, 11:42 PM
    If I have a generated class A which uses a class B, but I want to give the user the option to either write their own B or have B be created by my processor, is the correct way to do this to create a separate annotation which makes A's processor aware of this annotation over the class the user chooses as B, and if it is not present then generate?
    y
    a
    • 3
    • 6
  • j

    Jonas Bernemann

    08/14/2025, 1:02 PM
    Am I wrong for assuming that I should get all symbols again on a subsequent run when using
    getSymbolsWithAnnotation
    and having
    aggregating
    on true? Context: I am generating a Single Registry class for a bunch of classes annotated, all of the classes are listed in the
    kspDirtySet
    as inputs
  • h

    Hakan Mehmed

    08/26/2025, 8:22 PM
    Hi all, a quick note related to KSP 2.0.3
    Copy code
    KSP Gradle plugin 2.0.3 to require minimum AGP version 8.4.0+
    
    Please be aware that starting with version 2.0.3, the Kotlin Symbol Processing (KSP) Gradle plugin will introduce a new minimum requirement for the Android Gradle Plugin (AGP). To ensure your project continues to build successfully, you must use AGP version 8.4.0 or higher when using KSP 2.0.3 or any newer release. This will be a runtime requirement, meaning your builds will fail if you update KSP without also updating AGP to the required minimum version or a newer one.
    The reason for this is to allow cleaning up various runtime checks related to AGP version within KSP itself. If for any reason this version of AGP seems too new for your project using KSP, do let us know. We also plan to update the min AGP version as time progresses. :)
    👍 3
    thank you color 3