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

    Grégory Lureau

    11/13/2021, 8:57 AM
    Is it possible to get info on the implementation by delegation ?
    class Wrapper(
        _delegate: DepInterface
    ) : DepInterface by _delegate {
        [...]
    }
    I find the constructor parameter and the fact that
    Wrapper
    implements
    DepInterface
    , but I'm not able to find the
    by _delegate
    part. Also I was expecting to have the delegated method in
    getAllFunctions()
    I suppose I'll have to resolve() the super to get them?
    e
    • 2
    • 1
  • s

    salomonbrys

    11/15/2021, 11:26 AM
    New Multiplatform lib that uses KSP. However, since JS/IR is not properly supported by KSP, we needed to recommend a smelly workaround (process only JVM sources and use generated files on all targets). KSP of multiplatform is amazing! I hope we can get rid of this workaround soon 😉
    👍 2
    j
    • 2
    • 2
  • z

    Zac Sweers

    11/15/2021, 4:19 PM
    also - confirming an issue I’m seeing - 1.6.0-RC-1.0.1-RC does not include the new
    effectiveJavaModifiers()
    helper but 1.5.31-1.0.1 does?
    t
    j
    • 3
    • 4
  • g

    Grégory Lureau

    11/15/2021, 8:04 PM
    Looks like
    resolver.getSymbolsWithAnnotation(...)
    doesn't return annotated
    typealias
    , but still I can find them with
    resolver.getDeclarationsFromPackage(String)
    . Is it the expected behavior?
    j
    • 2
    • 12
  • j

    jameskleeh

    11/18/2021, 6:11 PM
    Is
    environment.codeGenerator.createNewFile(
    the way? It seems it expects a class file to be created
    :thread-please: 1
    j
    • 2
    • 1
  • j

    jameskleeh

    11/18/2021, 9:14 PM
    The FunctionKind is MEMBER, but there is no javadoc to describe what those function kinds mean
    y
    • 2
    • 5
  • a

    Alex Spence

    11/20/2021, 2:58 AM
    Hello - just ported my project from KAPT to KSP, so far experience has been great! But I'm having issues configuring the Gradle JVM Toolchain for the KspTask. Is there any documentation for how to set it up? For KAPT I had to add this snippet to my subProjects block:
    tasks.withType<org.jetbrains.kotlin.gradle.internal.KaptTask> {
            kotlinJavaToolchain.toolchain.use(customLauncher)
        }
    e
    • 2
    • 7
  • p

    PixelHamster

    11/20/2021, 4:36 PM
    Hi, is it possible to get the object class which was used in a companion object's constructor with ksp ?
    companion object : EntityClass<ULong, GuildSetting>(GuildSettings)
    from the companion object above I'd need the GuildSettings argument ? I'm rather new to ksp so I don't know all the jargon yet
    y
    e
    • 3
    • 6
  • e

    elect

    11/22/2021, 9:49 AM
    I'd like to generate some code for
    commonMain
    in a multiplatform project, is this supported? Because I only see the following configurations
    configuration ':ksp'
    configuration ':kspJvm'
    configuration ':kspJvmTest'
    configuration ':kspMetadata'
    configuration ':kspNative'
    configuration ':kspNativeTest'
    ➕ 1
    g
    p
    e
    • 4
    • 13
  • j

    janvladimirmostert

    11/28/2021, 9:39 AM
    when I add a
    kspJs
    configuration,
    dependencies {
       add("kspJvm", "io.jvaas:jvaas-observe")
       add("kspJs", "io.jvaas:jvaas-observe")
       //ksp("io.jvaas:jvaas-observe")
    }
    I get a failure with Execution failed for task ':applications:od-server:compileProductionExecutableKotlinJs'.
    Failed to calculate the value of task ':applications:od-server:compileProductionExecutableKotlinJs' property 'entryModule$kotlin_gradle_plugin'.
    > Collection has more than one element. Any ideas what this could be? I've posted the full code on https://stackoverflow.com/questions/70139266/ksp-on-kotlin-multiplatform-fails-on-the-kspjs-with-collection-has-more-than-on and a reproducible example here: https://github.com/janvladimirmostert/observable-demo
    j
    m
    • 3
    • 3
  • s

    Stewart Stewart

    11/30/2021, 7:50 PM
    Can ksp be used as a drop-in replacement for kapt with hibernate-jpamodelgen? When I tried it, no sources were generated.
    j
    a
    • 3
    • 5
  • y

    yigit

    12/01/2021, 12:52 AM
    Hi, We've created a new channel, #androidx-xprocessing for people who use the AndroidX abstraction for adding KSP support. Feel free to join there if you are using it. We'll use it to coordinate changes etc to avoid breaking early adopters.
    👍 2
    👍🏼 1
    k
    e
    • 3
    • 2
  • c

    Chris Mulder

    12/01/2021, 9:42 AM
    Hello, I would like to generate source code for different targets in a KMP project based on annotations in common. I would like to generate the following: • 1 expect class for common • 2 actual classes for Android and iOS. I am able to generate for one of the targets, depending on which configuration I add the ksp task to. This way I could run the processor per target and let it generate code per target. But it seems more appropriate to generate the code for all targets in one round, during kspMetadata, except that I do not know how to write the source code to other source sets than common from that task. Any suggestions on how to do this?
    y
    a
    • 3
    • 7
  • j

    jameskleeh

    12/01/2021, 6:29 PM
    Can anyone explain why
    returnType
    on
    KsPropertyGetter
    is nullable? In what cases would a getter not have a return type?
    j
    e
    • 3
    • 2
  • j

    jameskleeh

    12/02/2021, 7:38 PM
    How can I tell if a type parameter is a generic or concrete type?
    Array<String>
    vs
    Array<T>
    ?
    j
    y
    • 3
    • 8
  • r

    Rafael Costa

    12/03/2021, 10:12 AM
    Are
    SymbolProcessorEnvironment.options
    accessible by all ksp libraries users might be using or is there a way to define options by ksp library? Do you guys know of any open source library that uses these configuration options that I could take a look?
    y
    • 2
    • 4
  • h

    Hayden Meloche

    12/05/2021, 2:12 AM
    What would be the recommended way to copy a source code file from a KSP project into the generated sources folder of a project consuming my plugin?
    e
    b
    t
    • 4
    • 3
  • u

    Udi Cohen

    12/08/2021, 4:24 PM
    Is there a plan to improve support for delegations? Processing a class that has a delegation with KSP doesn’t provide all the expected information. For example:
    @KspTestingAnnotation
    class KspTesterDelegation : MainInterface by MainImpl() {
      fun method2(): Int {
        return 10
      }
    }
    
    interface MainInterface {
      fun method1(): Int
    }
    
    class MainImpl : MainInterface {
      override fun method1(): Int {
        return 4
      }
    }
    Getting all the declarations of
    KspTesterDelegation
    will only provide its constructor and
    method2()
    , while in KAPT we also get
    method1()
    . I know the reason KAPT can do that is because the generated stub has the delegated methods inside the main class. Is there a way I can still get the methods of a delegated class when using KSP?
    y
    • 2
    • 7
  • d

    Dilraj Singh

    12/11/2021, 11:57 AM
    Hi all, I have an annotation
    MyCustomAnnotation
    and a class of the following manner:
    @MyCustomAnnotation
    abstract class User {
        val id: Int = 11
        val name: String
    }
    Now I am trying to generate the following function using KSP:
    fun getUser(id: Int = 11, name: String): User {
        return User(id, name)
    }
    I am unable to get the value defined of the variable
    id
    , so the function generated has no default arguments. Any method to get the value of a class variable? Currently the following function is being generated:
    fun getUser(id: Int name: String): User {
        return User(id, name)
    }
    Thanks
    c
    a
    • 3
    • 4
  • z

    Zac Sweers

    12/13/2021, 7:03 PM
    I saw 1.0.2 fly by but no release notes. Pending?
    t
    • 2
    • 1
  • t

    Ting-Yuan Huang

    12/13/2021, 7:55 PM
    Hi there, here is the KSP 1.0.2 release for Kotlin 1.6.0. Most noticeable changes are: • Introduced a new API to mimic the behavior Kotlin JVM backend regarding with Java wildcard. • Fixed a few bugs around JS/IR. • Is compatible with slightly older Gradle versions (6.7+) again. And most importantly, thank you for all your bug reports, discussions, and pull requests!
    ❤️ 5
    🎉 9
    :kotlin-intensifies: 5
    • 1
    • 1
  • i

    Idan Nakav

    12/13/2021, 10:11 PM
    Hi everyone, does KSP require multiple kotlinc invocations in order to output the final class files (first to run the ksp processors and then another invocation to do the actual compilation) or it’s technically possible to do the whole compilation in a single kotlinc call?
    t
    • 2
    • 2
  • r

    Rohil Chodankar

    12/14/2021, 11:25 AM
    Hi everyone, I am currently actively working to migrate from
    KAPT
    to
    KSP
    in our android project. We have one internal processor that generates an extension function to convert a String into respective class type. Code snippet below. Everything works well and
    ksp
    generates the class. The problem I am facing is that some classes have companion object function that try to access the generated function. The IDE fails to resolve the generated function (although i have marked the generated path as explained) and intermittently the build task fails.
    @MyAnnotation
    enum class Test {
      @Field(name = "value1") value1,
      @Field(name = "value2") value2,
    
      companion object {
        fun fromString(value: String?): Test? = value?.toTest()
      }
    }
    • 1
    • 1
  • p

    philglass

    12/14/2021, 11:30 AM
    Has anyone tried writing tests for incremental scenarios? I don’t think it’s currently possible with
    kotlin-compile-testing
    (e.g. it fully wipes output directories on each KSP run, and a bunch of the KSP incremental behaviour is implemented by the Gradle plugin rather than the compiler plugin). Is my best bet more of an integration test, maybe using Gradle TestKit?
    j
    • 2
    • 2
  • j

    jameskleeh

    12/15/2021, 4:31 PM
    Update: It seems like the primitive is always used. I guess I’ll just have to do the mapping myself
    y
    • 2
    • 7
  • j

    jameskleeh

    12/21/2021, 4:19 PM
    @Jiaxiang Does that seem expected or should I file an issue?
    :thread-please: 2
    j
    • 2
    • 7
  • n

    Nikita Klimenko [JB]

    12/22/2021, 12:25 PM
    Hi! What is the current status of IDE support? https://github.com/google/ksp/issues/37 Do i understand it correctly that indexing of generated sources requires an IDE plugin, but 1. You cannot access required extension point because there is no published dependency (?) 2. Current kapt plugin is bundled with Kotlin plugin. Creating a plugin for KSP implies that people would need to install it separately.
    j
    z
    • 3
    • 3
  • j

    jameskleeh

    12/22/2021, 9:30 PM
    I’m trying to get the fully qualified name of an annotation that isn’t on the classpath. Unfortunately KSAnnotation only has
    shortName
    . It looks like the FQN is there in the descriptor, but I don’t know how to access it. Anyone have any idea? Thanks in advance
    y
    j
    • 3
    • 6
  • b

    bezrukov

    12/23/2021, 3:51 PM
    Hi, is there a way to add ksp argument to all subprojects applied ksp plugin?
    project.plugins.withType(com.google.devtools.ksp.gradle.KspGradleSubplugin).whenPluginAdded {
       ksp {
          arg("key", "value")
       }
    }
    doesn't work, because it can't find a plugin with that type. But it's there - I tried to find it without
    withType
    filtering (e.g.
    project.plugins.whenPluginAdded { println(it) })
    z
    e
    • 3
    • 4
  • d

    dvdandroid

    12/27/2021, 7:00 AM
    Why
    classDeclaration.getAllSuperTypes()
    returns an empty set when calling it with
    kspKotlinMetadata
    task in a multiplatform project? I'm trying to generate common code;
    kspKotlinJvm
    works fine
    j
    • 2
    • 3
Powered by Linen
Title
d

dvdandroid

12/27/2021, 7:00 AM
Why
classDeclaration.getAllSuperTypes()
returns an empty set when calling it with
kspKotlinMetadata
task in a multiplatform project? I'm trying to generate common code;
kspKotlinJvm
works fine
j

Jiaxiang

01/03/2022, 9:03 PM
This might be due to an issue we previously thought has been fixed. Can you provide mode details on it? A reproduce case would be ideal.
d

dvdandroid

01/04/2022, 11:23 AM
@Jiaxiang https://github.com/DVDAndroid/ksp-test-maybe-bug
👍 1
check readme
View count: 2