https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ksp
  • a

    atlantis210

    06/09/2022, 12:32 PM
    Hi, this is not a strictly KSP-related question... I succeeded in creating my own processor with the use of
    KotlinPoet
    and implemented it in the same project on IntelliJ and everything works fine. Now, I'm trying to import my compiled processor into my android project, but I don't succeed... I do the
    ./gradlew build
    and retrieve the
    processor.jar
    . I imported this into the
    libs
    folder, but when I'm trying to run the android project, I have a
    NoClassDefFound
    on
    com.squareup.kotlinpoet.FileSpec
    . I tried excluding the transitivity because I have a use of another version of KotlinPoet, 1.11 vs 1.10.2, but in both
    FileSpec
    exists... It's as if the jar is not including dependencies... I didn't find anything similar on the internet... I'm quite in a struggle here ^^"
    e
    j
    • 3
    • 4
  • v

    Vladimir Tagakov

    06/09/2022, 8:03 PM
    Hi I have class hierarchy like:
    abstract class BaseClass<TypeParam>
    
    abstract class IntermediateClass<TypeParam> : BaseClass<TypeParam>
    @MyAnnotation class MyClass: IntermediateClass<String>
    
    
    abstract class AnotherIntermediateClass: BaseClass<Int>
    @MyAnnotation class AnotherMyClass: AnotherIntermediateClass
    All classes having
    @MyAnnotation
    are extending
    BaseClass
    in one way or another. Can’t figure out how to get the types parametrizing
    BaseClass
    for
    MyClass
    and
    AnotherMyClass
    can someone help me here please?
    j
    • 2
    • 4
  • p

    Paul Woitaschek

    06/09/2022, 8:47 PM
    Can we get a 1.7.0 build? 🤞
    j
    • 2
    • 1
  • v

    Vladimir Tagakov

    06/09/2022, 11:38 PM
    Is it a bug that I can resolve an annotation type only when the annotation is declared at top-level? If annotation is nested inside a class it won’t resolve:
    val annotation: KSAnnotation = //...
    annotation.annotationType.resolve() // only resolves when annotation is not nested in a class
    j
    • 2
    • 5
  • j

    Jiaxiang

    06/10/2022, 6:20 AM
    here is the corresponding 1.7.0-1.0.6 release.
    👍🏼 1
    👍🏻 1
    ❤️ 5
    p
    • 2
    • 1
  • m

    Michal Klimczak

    06/15/2022, 1:07 PM
    I'm struggling with source sets config with my ksp processor - there seems to be a lot of changes in the topic recently, so can anyone tell me how to achieve generating code for
    iosMain
    source set? I'm using ksp 1.6.21-1.0.5 and even if I do
    configurations
            .filter { it.name.startsWith("ksp") }
            .forEach {
                add(it.name, "com.example...")
            }
    all I get is android source sets. If I try to add to ios configs, it doesn't complain but no code is generated. (the annotated files are in
    commonMain
    btw). An example of os library which generates code for different source sets would be awesome.
    o
    e
    • 3
    • 6
  • d

    David Rawson

    06/19/2022, 1:13 AM
    I am trying to understand Example 2 in the Incremental Processing documentation: https://kotlinlang.org/docs/ksp-incremental.html#example-2 I don’t understand the following statement:
    When
    sourceA
    is removed, nothing needs to be reprocessed.
    Why is this the case? If
    outputB
    is aggregating then changes in
    sourceA
    will mean reprocessing but why not removal of
    sourceA
    ?
    j
    • 2
    • 1
  • r

    Robert Jaros

    06/19/2022, 4:27 PM
    For typical fullstack setup (common, js, jvm source sets) I would like to process common sources and generate new sources for all three targets. Should I use three different processors or there is some way to know which source set is being processed?
    o
    • 2
    • 2
  • r

    Robert Jaros

    06/19/2022, 5:17 PM
    Can I apply ksp gradle plugin from my own gradle plugin?
    j
    • 2
    • 39
  • v

    Vladimir Tagakov

    06/23/2022, 11:49 PM
    Is there any support for flexible types? Maybe someone can give me a hint how to convert parametrized flexible type to e regular one? (assuming that I don’t have nullable types that come from java)
    j
    • 2
    • 5
  • d

    Doni Winata

    06/28/2022, 7:51 AM
    Is it safe to enable KSP only on some submodule? So module A using KSP, but module B using KAPT. I tried it and my build success, but not sure if there any side effect from this.
    n
    j
    • 3
    • 5
  • g

    Gustavo Gelape

    06/28/2022, 6:13 PM
    Hey there folks, I’m trying to run the Symbol Processing API on my instrumented tests (androidTest folder) so i can grab their annotation and add all the class names to a file using KSP, but the KSP stuff doesn’t go through the androidTest folder by default, i tried to add it like this:
    kotlin {
            sourceSets.debug {
                kotlin.srcDirs += 'src/androidTest/java/com/example/project'
            }
        }
    But then everything build related starts to fail since we use a lot of testImplementation, Dagger Hilt, etc. So, my question is, by any chance anyone know a way to include test folders in symbol processing (KSP) without adding them as sourceSets?
    j
    • 2
    • 4
  • j

    Jake Woods

    06/29/2022, 7:01 AM
    Is there any easy way in KSP to get the closest common ancestor of two
    KSType
    ? I’m doing the resolution with a hand-written algorithm right now and it feels wrong
    j
    • 2
    • 4
  • m

    Michal Klimczak

    06/29/2022, 10:58 AM
    I get
    Compilation failed: IrPropertyPublicSymbolImpl for com.example/myProperty|-7852496772092453113[0] is already bound: PROPERTY name:myProperty visibility:public modality:FINAL [val]
    
     * Source files: 
     * Compiler version info: Konan: 1.6.21 / Kotlin: 1.6.21
     * Output kind: PROGRAM
    myProperty
    is a top level property generated via ksp. This happens when trying to add ksp generated src dirs to different apple targets. The code is generated only once in
    kspCommonMainKotlinMetadata
    . Then if I add
    kotlin.srcDir("${project.buildDir.absolutePath}/generated/ksp/metadata/commonMain/kotlin")
    to each configuration, this error appears. It works fine if I only add it to the aggregating configuration (e.g.
    appleMain
    ), but it's something that can only get me so far, because I'm trying to automate it with a compiler plugin.
    👀 1
  • n

    Norbi

    07/06/2022, 8:32 AM
    Is there a plan to merge this PR anytime soon? I have difficulties setting up multi-module + multi-platform projects with KSP 😐 Thanks. https://github.com/google/ksp/pull/1021
    j
    • 2
    • 1
  • e

    elihart

    07/07/2022, 11:09 PM
    Is anyone else affected by https://github.com/google/ksp/issues/1034 or looking into it? It seems to be blocking our update to Kotlin 1.7
    j
    • 2
    • 13
  • j

    Jiaxiang

    07/07/2022, 11:39 PM
    Kotlin 1.7.10 was released today, here is the corresponding 1.7.10-1.0.6 release.
    🔥 10
    🎉 9
    :60fps_parrot: 2
    🚀 6
  • l

    Lukasz Kalnik

    07/09/2022, 11:07 AM
    I have an Android project using build flavors (
    devDebug
    ,
    sprintRelease
    ,
    playRelease
    ). So there is no ksp generated code in
    main
    , only in the respective flavor directories. How do I make Android Studio aware of the generated code to have it recognize generated symbols and provide autocompletion? This doesn't work, as there is no generated code in `main`: https://kotlinlang.org/docs/ksp-quickstart.html#make-ide-aware-of-generated-code
    o
    • 2
    • 4
  • n

    Norbi

    07/11/2022, 7:26 PM
    I use KSP in a multi-platform multi-module project with Idea CE. (But currently KSP is applied only on one JVM project.) The processor implementation is in a separate project (
    project-processor
    ), and it depends on another local project (
    project-annotations
    ) containing the annotation class triggering my processor to be applied. When I try to build or clean the whole project, I often run into that the JAR file of
    project-annotations
    is locked and therefore cannot be deleted. After I stop all Gradle daemons using
    gradlew --stop
    and retry the build/clean then it always succeeds. So it seems that the build artifact of
    project-annotations
    is locked by a Gradle daemon(s) which executed my processor from
    project-processor
    - and not only during the build but for longer term. (I use Kotlin 1.7.10 and the latest compatible KSP plugin.)
    Unable to delete directory '...\project-annotations\build'
      Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
      - ...\project-annotations\build\libs\project-annotations-jvm-1.0.0-SNAPSHOT.jar
      - ...\project-annotations\build\libs
    Haven't you run into a similar problem?
    e
    • 2
    • 3
  • c

    changd

    07/12/2022, 3:45 AM
    How can i get access to the project base directory in the context of the
    process
    function? Not saying it's the right thing to do, but our existing code writes to other directories in a multi-module project.
    j
    • 2
    • 9
  • j

    jameskleeh

    07/13/2022, 2:38 AM
    Hey folks, I need to call
    environment.codeGenerator.createNewFile(
    and create a file in a directory that contains
    .
    in it. Example path:
    META-INF/services/a.b.c/d.e.f
    where
    d.e.f
    is a file name. Is this possible? Currently passing that path as the package name results in
    META-INF/services/a/b/c/d.e.f
    j
    • 2
    • 4
  • c

    changd

    07/13/2022, 8:49 PM
    does ksp have performance logging like kapt? https://kotlinlang.org/docs/kapt.html#measuring-the-number-of-files-generated-with-annotation-processors
    j
    e
    • 3
    • 4
  • s

    Snail

    07/15/2022, 6:24 AM
    Hey, does KSP has some kind of intellij idea support for real time reprocessing? Say, you change relevant piece of code, it triggers processor. I assume that's not a thing yet and will require ide plugin, and the processor execution itself is quite expensive. For now, the only way i found to actually trigger the processor is to build the project. Am i wrong? Is there a correct way to use it?
    j
    • 2
    • 2
  • v

    v79

    07/17/2022, 7:51 AM
    Very new to #ksp - not even sure if this is what I want. Say I have a project with two modules, A and B. A contains the
    main
    function. B contains a class with a DSL that I'm very interested in interrogating. Is that something #ksp can do for me? So when A
    main
    runs, it can iterate over some values in the DSL class in B? I'm probably not even clear what I want...
    d
    • 2
    • 11
  • j

    juliocbcotta

    07/18/2022, 1:38 PM
    How can I try a snapshot version of ksp ? Can I just add the repository as a dependency somehow ?
    t
    j
    • 3
    • 10
  • r

    Roberto Leinardi

    07/19/2022, 2:41 PM
    Hi everyone, quick question: is it currently possible to read the default value of a property of a data class? For example, if I have the following data class annotated with `@MyAnnotation`:
    @MyAnnotation
    data class MyDataClass(
        val foo: Boolean = true,
        val bar: Int = 123,
        val buz: String? = "abc",
    )
    Is it possible to get the default values out of the
    KSPropertyDeclaration
    or in some other way?
    j
    • 2
    • 1
  • r

    rcd27

    07/21/2022, 10:14 AM
    Greetings. Thinking about triggering some events on function calls. For example
    @TriggerLoggingOnCall fun foo()
    . As soon as
    KSP
    does not modify the source code, I can't call just
    logThat()
    in the function body. The question is: can close my task with
    KSP
    ?
    e
    • 2
    • 1
  • t

    Ting-Yuan Huang

    08/02/2022, 7:40 AM
    Hello, here is a corresponding KSP release for Kotlin 1.7.20-Beta: https://github.com/google/ksp/releases/tag/1.7.20-Beta-1.0.6
    u
    • 2
    • 2
  • h

    Hamza GATTAL

    08/02/2022, 10:52 PM
    KSP will support dagger and hilt when reaching version 2.0.0 (just expecting) Is there anyone who can explain the reason for the delay?
  • z

    Zac Sweers

    08/02/2022, 11:17 PM
    Not sure what’s informing that expectation, but there is already an existing issue on the dagger repo you can subscribe to to follow KSP progress.
    j
    • 2
    • 1
Powered by Linen
Title
z

Zac Sweers

08/02/2022, 11:17 PM
Not sure what’s informing that expectation, but there is already an existing issue on the dagger repo you can subscribe to to follow KSP progress.
j

Jiaxiang

08/02/2022, 11:25 PM
Also dagger is a quite complicated use case, I would expect quite a period of time will be needed.
View count: 5