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
  • z

    Zac Sweers

    09/22/2021, 4:48 PM
    we see this pretty consistently in our project, anything I can do to help diagnose/rootcause it?
    kotlin scripting plugin: applied in the non-supported environment (error received: Cannot query the value of task ':libraries:foundation:feature-flag:compiler:kspKotlin' property 'sourceSetName$kotlin_gradle_plugin' because it has no value available.)
    kotlin scripting plugin: applied in the non-supported environment (error received: Cannot query the value of task ':libraries:foundation:carbonite:carbonite-compiler:kspKotlin' property 'sourceSetName$kotlin_gradle_plugin' because it has no value available.)
    t
    • 2
    • 4
  • j

    Jiaxiang

    09/22/2021, 10:55 PM
    Hi, here is a minor release for kotlin 1.5.31: https://github.com/google/ksp/releases/tag/1.5.31-1.0.0 This release is only about bumping kotlin compiler version, otherwise identical to 1.5.30-1.0.0 release. If you are not updating kotlin version to 1.5.31, you can ignore this release.
    👍🏼 1
    👍 5
    • 1
    • 1
  • s

    star_zero

    09/24/2021, 6:06 AM
    When
    aggregating
    of
    Dependencies
    is set to
    true
    , will even file changes that are not related to a particular annotation be reprocessed?
    val symbols = resolver.getSymbolsWithAnnotation("Factory")
    symbols.forEach { symbol ->
        val ksClass = symbol as KSClassDeclaration
        val packageName = ksClass.packageName.asString()
        val className = ksClass.simpleName.asString()
    
        val file = codeGenerator.createNewFile(
            Dependencies(true, ksClass.containingFile!!), // <--
            packageName,
            "${className}Factory"
        )
    
        // generate code ...
    }
    t
    • 2
    • 5
  • z

    Zac Sweers

    09/25/2021, 7:59 PM
    We see this failure on Kotlin 1.6-M1, worth filing or known?
    Caused by: java.lang.NoSuchMethodError: 'org.gradle.api.provider.Property com.google.devtools.ksp.gradle.KspTaskJvm.getUseClasspathSnapshot()'	
    	at com.google.devtools.ksp.gradle.KspTaskJvm.configureCompilation(KspSubplugin.kt:511)	
    	at com.google.devtools.ksp.gradle.KspGradleSubplugin$applyToCompilation$kspTaskProvider$1.execute(KspSubplugin.kt:335)	
    	at com.google.devtools.ksp.gradle.KspGradleSubplugin$applyToCompilation$kspTaskProvider$1.execute(KspSubplugin.kt:330)	
    	at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44)	
    	at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44)
    t
    • 2
    • 1
  • z

    Zac Sweers

    09/25/2021, 8:00 PM
    and related - would y'all consider mirroring Kotlin's milestone/rc releases too? We do extensive testing against preview releases and it would be a real bummer if we lost that ability with KSP. We've caught dozens of bugs early and been able to report them before stable release that way
    y
    t
    +2
    • 5
    • 28
  • w

    William Reed

    09/28/2021, 6:36 PM
    are there any drawbacks of using
    ksp
    in a project that uses
    kapt
    for all other annotation processors? or is it that i just won’t see the speed improvements from using
    ksp
    ?
    👍🏻 1
    t
    • 2
    • 2
  • w

    William Reed

    09/29/2021, 1:50 PM
    is this the correct approach at pulling out an annotation argument?
    parameter.annotations.firstOrNull { annot ->
        annot.annotationType.resolve().isAssignableFrom(annotationType)
    }?.arguments?.firstOrNull()?.let { annotation ->
        foo = (annotation.value as? String)
    }
    i’m not used to casting like this, so just checking i’m not going down the wrong path
    j
    • 2
    • 1
  • m

    Matthew Laser

    09/29/2021, 2:47 PM
    hey gang - in doing some searching I haven't seen this topic broached in a bit. is there any straightforward recipe for combining KSP with an android library? I've been trying to cram the
    com.android.library
    plugin into the KSP Quickstart's
    test-processor
    module without much luck
    e
    w
    • 3
    • 13
  • g

    Grégory Lureau

    09/30/2021, 2:51 PM
    Hello ! Didn't find a way to define a unit test to validate my own compiler. Is there some documentation somewhere or a reference example by any chance?
    j
    e
    +2
    • 5
    • 10
  • e

    elihart

    09/30/2021, 9:42 PM
    FYI, Paris now supports KSP as of its recent 2.0.0 release. Implementation was done with XProcessing to keep compatibility with KAPT. If you’re interested you can see the changes at https://github.com/airbnb/paris
    🎉 5
    • 1
    • 1
  • g

    Grégory Lureau

    10/01/2021, 3:28 PM
    Looks like
    Resolver.getSymbolsWithAnnotation
    only returns annotations available in the same compilation/gradle module for KMP. When I move the annotation to another module (dedicated to annotations) it's not returned anymore. Have you already experienced something similar ?
    e
    j
    g
    • 4
    • 11
  • w

    William Reed

    10/01/2021, 6:45 PM
    as a general annotation processing question: how can i write unit tests for one? I can check the compilation output with the
    kotlin-compile-testing
    library, but I’m interested in testing the functionality. Is the best option to create a new module which depends on the annotation processor and run tests there?
    y
    • 2
    • 8
  • z

    Zac Sweers

    10/02/2021, 1:16 AM
    I've noticed in our project that having both KSP and kapt enabled in a project results in corrupted incremental compilation data. Should I file an issue for this or would it fall under the category of "interop with kapt is undefined behavior"?
    t
    • 2
    • 2
  • g

    Grégory Lureau

    10/03/2021, 9:00 PM
    Playing with KSP on a multiplatform project, compilation is crashing because of multiple classesDirs (as I understand it). It's crashing in KotlinJsIrLink:l54 where the code use a .single() on a list that (I suppose) has the classes dir + the generated dir. Is my understanding correct and should I discuss this in multiplatform/JS instead?
    t
    a
    • 3
    • 8
  • r

    Rafael Costa

    10/04/2021, 12:06 AM
    Hi all! I was wondering, is checking if the app has some dependency a valid use case when using KSP? Like imagine, if the user of my KSP library has a certain dependency, then I want to generate some classes a bit differently? I seemingly managed to do this by calling
    resolver.getDeclarationsFromPackage("com.some.package").iterator().hasNext()
    , but I was wondering if there is a better/more performant way.
    y
    • 2
    • 5
  • v

    Vaios Tsitsonis

    10/04/2021, 6:49 AM
    Hello! I ve created a KSP processor and everything goes fine! It generates the classes that I want. The problem is that I want to use it only during testing, so when I change ksp into kspTest the classes are not generated anymore. Is there any limitation/issue? Should I generate these classes in my app and let proguard do its job while having these classes accessible to my tests?
    y
    • 2
    • 1
  • w

    William Reed

    10/04/2021, 3:03 PM
    Hi guys - it seems like when I have a annotated data class in a function it is not getting recognized with
    resolver.getSymbolsWithAnnotation
    class Foo {
        fun bar() {
            @SomeKspAnnotation
            class Hello()
        }
    }
    I’m only doing this for a unit test, so i can work around it in my real code. just wondering if it’s a known issue
    y
    • 2
    • 2
  • r

    rkeazor

    10/05/2021, 3:27 PM
    Is there a good blog post about migrating your custom annotation processor from kapt to ksp?
    e
    w
    +3
    • 6
    • 6
  • m

    miqbaldc

    10/06/2021, 6:23 AM
    This might be already questioned elsewhere (not sure what was the keyword) Did we need to wait for library author to support KSP, or we can just replace
    kapt
    with
    ksp
    ? 🙏
    e
    • 2
    • 2
  • e

    eygraber

    10/06/2021, 6:17 PM
    If I want to build a processor (and annotations to use with it) should those module apply the Kotlin jvm plugin, or multiplatform plugin?
    e
    • 2
    • 2
  • b

    Big Chungus

    10/10/2021, 9:07 PM
    Are there any guides/examples of ksp MPP processors and their usage?
    👀 2
    t
    • 2
    • 1
  • g

    Grégory Lureau

    10/11/2021, 10:41 AM
    Hello ! I've a KMP project with 2 modules, one define a class, the other defines an interface that returns the class from the other module. When processing the interface, I'm only able to retrieve the name from
    func.returnType.toString()
    but
    resolve()
    only returns empty/null/"<Error>". Is it something already known or covered by pull/609?
    j
    • 2
    • 8
  • z

    Zac Sweers

    10/12/2021, 12:30 AM
    I noticed that kapt is set up to depend on KSP. In all our cases though, they have no dependencies. Is there a way to break this dependency so they can work in parallel?
    t
    • 2
    • 4
  • g

    Grégory Lureau

    10/12/2021, 8:07 AM
    Is there some ways to get the input kotlin file content directly? I'd use a regex on the file content to grab some imports as a workaround for the resolve() issue mentioned earlier.
    j
    • 2
    • 1
  • l

    len

    10/12/2021, 7:40 PM
    Is there any way to run KSP before the
    processManifest
    task? KSP adds a dependency on the
    processResources
    task (which also depends on
    processManifest
    ). I've tried to remove it from
    dependsOn
    but somehow it's never removed and I end up with cyclic dependencies. I want to generate a class with KSP and add a reference to it in
    AndroidManifest.xml
    for dynamic loading
    👀 1
    t
    • 2
    • 2
  • l

    Lilly

    10/12/2021, 10:48 PM
    Hi I'm trying to bother with KSP. I have a simple use case: deserialize line of Strings coming from a csv file to a data class with type conversion. It might be overpowered to do this with KSP, but I would like to use this chance to learn annotation processing etc. Can someone give me a blueprint how this mapping with conversion would look like on the basis of an example (not the glue, just the processing code)? Or is someone aware of an example that matches my use case?
    e
    p
    • 3
    • 3
  • s

    star_zero

    10/13/2021, 9:03 AM
    Is it possible to analyze the code generated by KAPT with KSP?
    j
    • 2
    • 2
  • w

    William Reed

    10/13/2021, 1:48 PM
    given a
    KSType
    , how can I tell if it is an enum? i’m looking into obtaining a
    KSClassDeclaration
    for
    Enum<*>
    t
    • 2
    • 3
  • r

    rocketraman

    10/13/2021, 2:22 PM
    I'd like to implement the equivalent of an "around advice" aspect for some auditing functions. Is KSP a reasonable tool to use? If yes, are there any examples doing something similar that I can look at?
    w
    j
    +2
    • 5
    • 8
  • j

    jameskleeh

    10/13/2021, 4:32 PM
    I’m finding that
    resolver.getClassDeclarationByName
    is not finding already compiled Java classes in a jar that is on the classpath. Is that expected? Using 1.5.30-1.0.0
    y
    • 2
    • 3
Powered by Linen
Title
j

jameskleeh

10/13/2021, 4:32 PM
I’m finding that
resolver.getClassDeclarationByName
is not finding already compiled Java classes in a jar that is on the classpath. Is that expected? Using 1.5.30-1.0.0
y

yigit

10/13/2021, 4:39 PM
that looks like a bug, we have tests in Room that validate compiled classes. can you file a bug w/ a repro project ?
j

jameskleeh

10/13/2021, 4:46 PM
I can
Turned out to be an issue on my end. I’m using the KSP test compilation stuff and
inheritClasspath
is set to false by default
View count: 7