https://kotlinlang.org logo
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
  • k

    KD

    02/11/2021, 1:37 AM
    Hi everyone 👋 😄 . New to meta-programming and wanted to make sure if this is the best resource to learn about KSP? Thank you!
    y
    • 2
    • 2
  • f

    Fabio

    02/11/2021, 7:38 AM
    Hi, I created a simple processor and a JVM library module that uses it. But when I try to apply it to either an Android library or Android application I get gradle configuration errors. Is there any Android examples out there?
    y
    s
    • 3
    • 3
  • b

    Big Chungus

    02/11/2021, 3:19 PM
    Hi. Is ksp still tied to jvm or is it finally mpp? Also is it in the same niche of tooling as arrow-meta?
    y
    j
    • 3
    • 2
  • j

    Jiaxiang

    02/11/2021, 11:06 PM
    @Zac Sweers can you give me a reproduce repo for your
    CompilationErrorException
    use case?
    z
    a
    t
    • 4
    • 4
  • s

    star_zero

    02/12/2021, 9:29 AM
    How can I get annotations from a property?
    data class Sample(
        @Json(name = "full_name") val fullName: String
    )
    
    // in KSP
    KSClassDeclaration.getAllProperties().forEach {
        it.annotations // => empty list
    }
    t
    • 2
    • 3
  • p

    pajatopmr

    02/13/2021, 8:26 AM
    KSP just came across my radar. At first glance, it looks like an awesome tool to support the development of Kotlin related LSP clients and servers, for which I am working on both. The answer to this question will be telling: given a hello world program that contains
    println("Hello World")
    can KSP easily access the declaration of "println"? I.e. can KSP drill into the runtime jar file, extract the definition/declaration of standard language symbols and provide those to an interested tool leveraging KSP?
    🇳🇴 1
    j
    s
    • 3
    • 6
  • z

    Zac Sweers

    02/14/2021, 5:00 AM
    would you be up for making SymbolProcessor.onFinish have a no-op default implementation? I find I never implement it in the processors I've written
    ➕ 1
    j
    • 2
    • 3
  • z

    Zac Sweers

    02/14/2021, 6:34 AM
    another qq - I saw the new test configurations followed kapt's
    <config>Test
    naming convention rather than the conventional
    test<config>
    convention used everywhere else. Was there a specific reason for this? If not - would you be open to changing it? This is always a huge headache when repo maintainers try to automatically manage some configurations for tests and have to add special rules for kapt's backward naming
    y
    t
    f
    • 4
    • 31
  • z

    Zac Sweers

    02/16/2021, 6:46 PM
    I'm looking at making a PR for sealedSubclasses. It looks fairly simple, the only hard part is making sure it works with incremental. I can kind of eyeball how other APIs support it, but I'd be curious if there's any docs/guidelines for it. I could also start with a PR of what I have and continue in there if that's easier, let me know
    t
    e
    • 3
    • 11
  • f

    Fabio

    02/16/2021, 10:20 PM
    How would I get the class of a KSPropertyDeclaration? I can see
    it.type.resolve()
    is a
    KSType
    , and I see
    isAssignableFrom(KSType)
    but still not sure how to compare it to a
    KClass
    like
    Module::class.java
    y
    j
    • 3
    • 15
  • y

    yigit

    02/18/2021, 8:02 PM
    we've shipped first version of Room that supports KSP: https://developer.android.com/jetpack/androidx/releases/room#2.3.0-beta02
    🎉 21
    l
    t
    • 3
    • 2
  • y

    yamasa

    02/19/2021, 4:49 PM
    Suppose a code like this:
    class Outer<T> {
        inner class Inner
    }
    
    val foo: Outer<String>.Inner
        get() = TODO()
    Is there a way to get the type argument
    String
    from
    KSPropertyDeclaration.type
    of the property
    foo
    ? I tried
    fooPropertyDeclaration.type.resolve().declaration.parentDeclaration?.typeParameters?.get(0)
    , but it was
    T
    , not
    String
    .
    y
    t
    • 3
    • 11
  • j

    Jiaxiang

    02/20/2021, 12:56 AM
    Hi, here is my planned change to how KSP should handle exceptions https://github.com/google/ksp/pull/321 (you can ignore the code change and only look at the document change on
    SymbolProcessor
    . I’d like to open up for discussion and hear back from you on how you think about this exception handling on how it can impact your developing experience (in good way or bad way). Mainly I would like feedbacks on whether other processors should continue processing when one processor throws an exception.
    z
    • 2
    • 7
  • e

    elihart

    02/22/2021, 5:07 PM
    Is there any equivalent in KSP for
    javax.lang.model.element.PackageElement
    ? As far as I can tell there isn’t a
    KSAnnotated
    representation of a package (potentially because package-info.java is not used in kotlin?) I have a javac processor that looks up annotations on package elements and am wondering how KSP handles that. Similarly, does KSP provide any way to resolve the package by name? In javac we can do
    Elements.getPackageElement(CharSequence)
    to get a package, which then provides access to all elements in that package (including elements from other modules). We have used this to enable a single module to aggregate the generated files of other modules, by putting them all in the same package. I’m trying to figure out how to translate this to KSP
    j
    g
    • 3
    • 23
  • g

    gabrielfv

    02/24/2021, 3:12 PM
    Hello, guys, I am wondering what are the practical differences of incremental processing to processors, and if I need to make anything specific to assure that a processor I created is incremental. After reading some documentation regarding KAPT, It seems to me that as long as the only code that change is internal code inside methods, symbol processing will not kick in. But as soon as there’s some other kind of change, the entire processing will be done from square one. I was wondering if that’s the case, or if it would mean symbol processing would only process symbols that changed (i.e.: new/modified annotated classes), while caching symbols that have been previously successfully processed, and passing the cached data down to processors along with what’s new.
    t
    • 2
    • 2
  • v

    Vladislav Areshkin [IceRock]

    02/27/2021, 5:05 PM
    👋 Am I understanding correctly that KSP only works with one Gradle module? So a symbol processor cannot process annotated classes from other Gradle modules?
    y
    g
    • 3
    • 4
  • y

    yigit

    02/27/2021, 8:12 PM
    I'm happy to hear that you liked it. Btw, you didn't need to copy that, it is already in gmaven, we just don't advertise it as a standalone library. There is always an option that we might make it more visible but this ksp-room project had enough many moving pieces and i didn't want to add more complexity.
    e
    • 2
    • 4
  • y

    yigit

    02/27/2021, 8:13 PM
    We are also considering using it for dagger but the apis are haavily optimized for kotlin and most of dagger is in Java so may not work well.
    e
    • 2
    • 2
  • z

    Zac Sweers

    02/27/2021, 8:26 PM
    ah no I meant in kotlinpoet directly, as another artifact. To cover some simple cases of KS* types to KotlinPoet
    t
    • 2
    • 1
  • y

    yigit

    02/27/2021, 8:33 PM
    Would be great to have all of it out of the box
    e
    z
    e
    • 4
    • 19
  • y

    yigit

    02/27/2021, 8:37 PM
    This is what we have: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:room/compiler-processing/src/main/java/androidx/room/compiler/processing/ksp/KSTypeExt.kt
    e
    z
    • 3
    • 3
  • y

    yigit

    03/01/2021, 9:08 PM
    ok i talked w/ AndoridX folks and got the buy in to ship the testing artifact. We'll annotate them w/ some requires opt in though and will still NOT advertise (so no API stability, release notes etc, for now). as things progress, we can consider upgrading it to a real library if it becomes useful for many libraries. meanwhile, i highligy recommend proguarding it. Idk if javaap or KSP does any classloader isolation
    🎉 3
    t
    e
    • 3
    • 10
  • y

    yigit

    03/01/2021, 9:11 PM
    https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:room/compiler-processing-testing/ it provides some APIs to run the same processing test w/ all 3 backends (javaap, ksp, kapt)
    👍 1
    g
    • 2
    • 1
  • s

    spierce7

    03/02/2021, 6:20 AM
    Does Compose use KSP?
    :stackoverflow: 1
    :nope: 2
    z
    y
    • 3
    • 3
  • t

    Timo Gruen

    03/09/2021, 9:58 AM
    Hi everyone, I’m currently searching for a way to simply test a KSP processor - any recommendations? (I already googled a little to find any library / way to simply test a KSP processor).
    • 1
    • 1
  • j

    Jiaxiang

    03/11/2021, 12:51 AM
    Hi, here is our biweekly release for KSP: https://github.com/google/ksp/releases/tag/1.4.30-1.0.0-alpha05 Highlights • synthetic property accessors now can be correctly created for abstract classes, align with compiler behavior. • Removed 
    findAnnotationFromUseSiteTarget()
     function, consolidate its functionality into KSP internal logic. Behavior change • KSP now handles annotation use site targets internally for property accessors (namely 
    @get:Anno
    , 
    @set:Anno
    ). ◦ property accessors will have corresponding targeted annotations from their receiver properties ◦ annotations with 
    @get:
     and 
    @set:
     targets will not appear in property’s annotation list.
    🎉 6
    j
    t
    m
    • 4
    • 8
  • y

    yigit

    03/17/2021, 1:06 AM
    for those who wants to play w/ Room's abstraction, i added a super simple README that should help you find your way around. https://github.com/androidx/androidx/tree/androidx-main/room/compiler-processing
    👍🏼 1
    👍 7
    • 1
    • 1
  • m

    Michal Harakal

    03/17/2021, 1:31 PM
    What is a recommended way to write simple test to KSP plugin? I've played with
    "com.github.tschuchortdev:kotlin-compile-testing
    a little bit, but not success yet. It works well with kotlinc plugins, even debugging is possible ...
    y
    • 2
    • 5
  • g

    gabrielfv

    03/17/2021, 7:06 PM
    I'm having a problem with compiler testing. For some reason, it does not detect KSP generated files. They have been successfully generated and it's possible to browse to them throught the file system, but they're not reported on the compilation result. It looks like it's looking for kapt generated stuff instead. Here's how I'm running it: <inside thread>
    y
    t
    • 3
    • 12
  • z

    Zac Sweers

    03/19/2021, 4:09 AM
    I see this warning coming from KSP - is that from kotlinc under the hood or something in KSP? If so - could that also be suppressed?
    w: Language version 1.5 is experimental, there are no backwards compatibility guarantees for new language and library features
    As it prevents us from using
    warningsAsError
    t
    • 2
    • 9
Powered by Linen
Title
z

Zac Sweers

03/19/2021, 4:09 AM
I see this warning coming from KSP - is that from kotlinc under the hood or something in KSP? If so - could that also be suppressed?
w: Language version 1.5 is experimental, there are no backwards compatibility guarantees for new language and library features
As it prevents us from using
warningsAsError
t

Ting-Yuan Huang

03/19/2021, 4:21 AM
Somehow
-language-version=1.5
is passed to the compiler. I'm not sure where it was set. It can be muted with
-Xsuppress-version-warnings
z

Zac Sweers

03/19/2021, 4:21 AM
ah great, thanks
t

Ting-Yuan Huang

03/19/2021, 4:23 AM
IIRC KSP doesn't set the language version. Could it come from the project being built?
z

Zac Sweers

03/19/2021, 4:26 AM
yeah I'm setting it to 1.5 for KotlinCompile tasks
also that flag doesn't seem to be available anymore
w: Flag is not supported by this version of the compiler: -Xsuppress-version-warnings
w: Language version 1.5 is experimental, there are no backwards compatibility guarantees for new language and library features
e: warnings found and -Werror specified
t

Ting-Yuan Huang

03/19/2021, 4:31 AM
how did you add the flag? by adding it to free args?
I mean kotlinOptions.freeCompilerArgs
z

Zac Sweers

03/19/2021, 3:25 PM
Yeah that’s where I tried adding it
View count: 2