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

    Zac Sweers

    05/19/2021, 11:17 PM
    I’m attempting to use
    blockOtherCompilerPlugins
    but I’m not sure I quite understand its intended use. I’m trying to disable Anvil from running during KSP’s tasks, but when I set this property to true I get an obscure NoSuchElementException coming from this line: https://github.com/google/ksp/pull/270/files#diff-a345032d6c965be6e81478437767cb750c83bd0a952014661e86d454ea5a342bR223 Is this the right way to use this?
    t
    • 2
    • 2
  • s

    spierce7

    05/24/2021, 5:39 PM
    @Ting-Yuan Huang Are we still going to see KSP enabled for multiplatform in Kotlin 1.5.20? 1.5.10 was just released, so I thought I’d check in 🙂
    👀 4
    😂 2
    t
    b
    • 3
    • 4
  • t

    Ting-Yuan Huang

    05/27/2021, 12:32 AM
    Hey everyone, we’re excited to announce the first beta release of KSP! Big thanks to everyone in this group for all of the helpful feedback over the last 3 months. The existing API should be mostly stable now and unlikely to change in the future. We'll do our best to minimize the compatibility / migration issues from now on. As for next steps, we'll be focusing on fixing bugs, tuning performance and multiplatform support. Please give it a try and let use know what's needed and what doesn't work!
    🎉 26
    👏🏼 1
    👏 18
    :kotlin-intensifies: 12
    t
    • 2
    • 1
  • z

    Zac Sweers

    05/31/2021, 8:11 PM
    for
    KSNode.origin
    I see Origin can be both
    KOTLIN
    or
    KOTLIN_LIB
    . Do both of those indicate that the node is a kotlin type? I'm curious what the distinction implies
    y
    • 2
    • 3
  • l

    lewis

    06/03/2021, 7:29 AM
    Not sure if this is best to post in #room or here, I upgraded to Compose beta08 today, which allowed me to jump to 1.5.10-1.0.0-beta01 of KSP. Since doing this (only version changes) KSP has stopped generating anything. I've tried Room 2.4.0-alpha02 and 2.3.0. Were there any Gradle configuration changes required for the jump from 1.4.32-1.0.0-alpha08 -> 1.5.10-1.0.0-beta01? Everything works fine if I switch back to kapt.
    e
    a
    +2
    • 5
    • 8
  • s

    Stephan Schroeder

    06/09/2021, 8:18 AM
    We have a pretty basic preprocessor task coming (generating a documentation file containing all the classes/methods in the project with a special annotation). Normally I'd use KAPT, since KSP is still in Alpha, but it's unclear if KAPT will support the new compiler frontend. So how is the situation with KSP? Does it already work with the new frontend? Since my task is so straight forward, I think, I'd be ok with updating/adapting my code through different alpha versions of KSP, or is this a bad idea?
    b
    e
    j
    • 4
    • 11
  • b

    Big Chungus

    06/09/2021, 9:14 AM
    Is it possible to retrieve all classes/interfaces implementing a particular interface with ksp?
    j
    • 2
    • 1
  • z

    Zac Sweers

    06/10/2021, 5:53 AM
    Any suggestions on a test case for my PR fixing bytecode post processing?
    t
    j
    • 3
    • 15
  • j

    jossiwolf

    06/16/2021, 7:20 AM
    Super basic question, how do y'all google questions around ksp? 🙈 Every time I try to google something ksp-related I only get things about Kerbal Space Program 😂
    🧑‍🚀 3
    🚀 6
    🧑‍🚀🏼 1
    w
    b
    +3
    • 6
    • 10
  • p

    Paul Woitaschek

    06/22/2021, 7:03 AM
    What's the state on ksp on multiplatform? According to some issues and merged PR's it seems that it might be supported, but the readme states that it's still on the roadmap.
    👀 6
    t
    j
    • 3
    • 4
  • e

    evant

    06/25/2021, 4:07 AM
    hm, will try to narrow it down more sometime later, but getting an error type somewhere just on js, can reproduce by running
    ./gradlew jsTest
    from the
    ksp-js
    branch https://github.com/evant/kotlin-inject/tree/ksp-js
    j
    • 2
    • 6
  • e

    elihart

    06/28/2021, 6:41 PM
    The alpha release blog post says
    using KAPT and KSP in the same module will likely slow down your build initially
    - however, we did some gradle profiling of our own project with KSP enabled and found that mixing KSP/KAPT actually is slightly faster than using only KAPT (if not all processors support KSP) I’m wondering if there is any more current information about mixing KAPT and KSP in the same module (since alpha release was a while ago), and I’m curious to hear about other people’s experience
    z
    j
    +3
    • 6
    • 14
  • a

    Alex Beggs

    07/07/2021, 5:11 PM
    I wrote some code to implement the
    getAnnotation
    in a separate repo. I saw that the implementation is pending for KSP and would like to know if I could help contribute there. If so I have a couple of questions. Which elements should we apply the functions to? I was thinking the KSAnnotated seems to make sense. ie
    KSAnnotated#getAnnotation
    I had also thought of taking a different approach and leveraging the
    Method#getAnnotation
    method by just getting a handle to the
    Method
    itself from the
    KSAnnotated
    , but I hadn’t done any further research into that yet. What approaches were you thinking about taking? And does my current implementation in my repo seem reasonable or is there a better approach? I had thought about just creating a PR, but I would rather get some feedback first before I invest the time. Thanks
    y
    t
    j
    • 4
    • 36
  • a

    Anton Popov

    07/12/2021, 6:05 PM
    Hi! I have a question: why KSNameImpl doesn't override equals method? Wouldn't it be easier to write this
    it.simpleName == shortName
    instead of this
    it.simpleName.asString() == shortName.asString()
    . Before looking into the impl, I even thought that calling
    asString()
    is not efficient, because conversion from some inner representation to String might happen.
    y
    t
    • 3
    • 12
  • a

    Alex Beggs

    07/13/2021, 2:17 AM
    Running the following command
    ./gradlew --stacktrace --info :compiler-plugin:test --tests "com.google.devtools.ksp.test.KotlinKSPTestGenerated.*" -PcompilerTestEnabled=true
    any idea how to fix the error below when I attempt to run the tests locally. Every test fails with the same error.
    com.google.devtools.ksp.test.KotlinKSPTestGenerated > testAnnotationOnConstructorParameter FAILED
        java.lang.NoClassDefFoundError: Could not initialize class sun.lwawt.macosx.LWCToolkit
            at java.base/java.lang.Class.forName0(Native Method)
            at java.base/java.lang.Class.forName(Class.java:292)
            at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:573)
            at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:568)
            at java.base/java.security.AccessController.doPrivileged(Native Method)
            at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:567)
            at com.intellij.testFramework.TestApplicationManagerKt.replaceIdeEventQueueSafely(TestApplicationManager.kt:156)
            at com.intellij.testFramework.TestRunnerUtil.replaceIdeEventQueueSafely(TestRunnerUtil.java:12)
            at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.runBare(KtUsefulTestCase.java:485)
            at junit.framework.TestResult$1.protect(TestResult.java:122)
            at junit.framework.TestResult.runProtected(TestResult.java:142)
            at junit.framework.TestResult.run(TestResult.java:125)
            at junit.framework.TestCase.run(TestCase.java:129)
            at junit.framework.TestSuite.runTest(TestSuite.java:252)
            at junit.framework.TestSuite.run(TestSuite.java:247)
            at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
            at org.jetbrains.kotlin.test.JUnit3RunnerWithInnersForGradle.run(JUnit3RunnerWithInnersForGradle.java:71)
            at org.jetbrains.kotlin.test.JUnit3RunnerWithInners.run(JUnit3RunnerWithInners.java:54)
            at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
            at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
            at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
            at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
            at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:564)
            at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
            at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
            at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
            at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
            at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
            at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:121)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:564)
            at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
            at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
            at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
            at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
            at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
            at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
            at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
            at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
            at java.base/java.lang.Thread.run(Thread.java:844)
    y
    j
    • 3
    • 10
  • s

    Stephan Schroeder

    07/13/2021, 12:10 PM
    So I log to my
    KSPLogger
    but the text doesn't show up in my
    ./gradlew build
    output. How do I change that? Or alternatively, where does the output show up?
    j
    • 2
    • 4
  • e

    evant

    07/14/2021, 2:12 PM
    ok finally got around to testing publishing a ksp processor with js support. It seems to work fine if the consuming project uses
    js(LEGACY)
    but it fails to run when it uses
    js(IR)
    . 🤔
    t
    • 2
    • 2
  • d

    Dario Valdespino

    07/17/2021, 7:12 PM
    Hi, one of the latest releases includes experimental support for KMP. Does this mean that I could generate code inside a Common module? If so, how would I do that?
    t
    e
    • 3
    • 5
  • z

    Zac Sweers

    07/18/2021, 6:38 PM
    would you ever consider allowing KSP to run embedded directly in kotlinc again? I understand why it's a separate task now, but I also wonder if that's something that could be configurable if none of the given processors require it. We're using Anvil pretty heavily (which wires into the same infrastructure) and the easy of just having it directly in the existing kotlinc tasks makes it really appealing to write new code generators using its infra rather than KSP
    ➕ 1
    t
    • 2
    • 7
  • z

    Zac Sweers

    07/20/2021, 3:07 PM
    Could KSP be published to maven central too? This is a lot of headache for Dagger users to have to add a custom repo even if they’re not using KSP https://github.com/google/dagger/releases/tag/dagger-2.38
    🚀 3
    ☝️ 4
    t
    • 2
    • 3
  • a

    Anton Popov

    07/23/2021, 3:45 PM
    Where does files with extensions, other than
    .kt
    and
    .java
    , get placed, when crating them using CodeGenerator? Will they get included in apk (in android project)? Use-case: I would like to transfer processed info from one compilation module to another in this file (just text file), and use it while processing another module. Right now I just place this "transfer file" in
    /module-name/build/generated/myProcessorName/transferFile
    , but I have A LOT of problems with gradle: after
    gradle clean
    my processor doesn't run (presumably gets in gradle cache) and, consequently, doesn't produce this transfer file. In gradle logs I see
    > Task :module-name:kspDebugKotlin FROM-CACHE
    . Will this problem go away if I will use CodeGenerator to create this transfer file? If yes, how can I do so without including the transfer file in final build artifact (apk)?
    j
    • 2
    • 6
  • j

    Jiaxiang

    07/26/2021, 7:51 PM
    playground is not part of our git history, we can check to see if there is any errors and update it
    t
    t
    • 3
    • 2
  • f

    Fudge

    07/28/2021, 7:57 AM
    Are calls to
    resolve()
    cached? as in, if I do something like this:
    a.resolve()
    a.resolve()
    Does this take double the amount of time, or is the second call much cheaper?
    j
    • 2
    • 1
  • f

    Fudge

    07/28/2021, 5:43 PM
    I feel like I don't understand incremental processing in KSP on a basic level. Say my processor uses class
    A
    by annotating
    A
    and calling ``resolver.getSymbolsWithAnnotation`, and I change class `B`(unrelated). Why does
    process
    get called? surely to save time it should not be called. At first I thought that
    resolver.getSymbolsWithAnnotation
    will return an empty sequence if only
    B
    was changed and
    A
    has not, but it does not. I get
    A
    in this invocation, and, at the end of the day, no time is saved and there is nothing incremental about this. So what exactly can be done to make processing code incremental? There is no flag
    stuffHasNotChanged
    .
    t
    • 2
    • 5
  • b

    Ben Schwab

    07/28/2021, 9:28 PM
    We recently ran an experiment using KSP at airbnb I did some analysis on the results: https://docs.google.com/document/d/1zqQ5cMeucvAZtzN94YIcryvaNK_8KiJwF0Uyof4x5rw/edit# Quick summary: • ~660/900 modules were eligible to use ksp • KSP helped most builds by about 10% in most percentiles, but dropped the performance of P95 builds P95 drop in performance is likely from remote cache incompatibility and worse incremental compilation than kapt (ksp.incremental.intermodule=true just landed to address this)
    👍 2
    t
    • 2
    • 4
  • g

    gmazzo

    08/02/2021, 1:24 PM
    Hi there! We are having a strange issue today where a generated
    META-INF/services/xxx
    (through
    ServiceLoader
    ) with a KSP processor is not present on the final APK. I noted latest version has added this change: https://github.com/google/ksp/blob/1.5.21-1.0.0-beta06/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/AndroidPluginIntegration.kt#L93 And seems to work on the test, but for some reason, it isn’t for us. It started working after I add this workaound:
    android.applicationVariant.all {
                processJavaResourcesProvider.configure {
                    from("$buildDir/generated/ksp/${this@all.name}/resources")
                }
            }
    Any idea why
    registerPostJavacGeneratedBytecode
    may not be enough? I did played a bit with the
    ksp
    ’s
    AndroidIT
    and it seems to work in there
    z
    • 2
    • 2
  • n

    Nikita Klimenko [JB]

    08/04/2021, 3:58 PM
    Hi! I'm working on the Gradle plugin and symbol processor. The use of that plugin implies that the symbol processor should also be used. So I have decided to create yet another Gradle plugin to reduce all necessary repository, dependency etc configurations to one line. The question is: to make IDE aware of the generated code I would add something like this in my build file:
    sourceSets {
       main.kotlin.srcDir("build/generated/ksp/main/kotlin/")
    }
    But should my plugin do this when applied to the project? Or should I leave this configuration to the end-user? I'm in such a dither over this because the KSP plugin itself doesn't add generated paths in source sets.
    e
    • 2
    • 2
  • n

    Nikita Klimenko [JB]

    08/06/2021, 4:47 PM
    Given the type reference to functional type, how would you use it in generated code so everything is resolved? Right now i resolve reference to KSType and then recursively its type parameters. For plain functional types resolved name is FunctionN, and generated code with those works fine. But for
    suspend () -> Unit
    SuspendFunction
    is unaccessible for user code :c So i think need something that converts
    suspend () -> String
    ->
    suspend () -> kotlin.String
    . Just want to make sure not to reinvent the wheel.
    t
    • 2
    • 3
  • j

    Jiaxiang

    08/13/2021, 12:53 AM
    Hi, here is the latest KSP release: 1.5.21-1.0.0-beta07 Highlights • starting this release, KSP binary has moved from gMaven to MavenCentral repo. • Kotlin native is now supported. • ksp.incremental.intermodule is enabled by default Issues resolved #60 Using KSP with Kotlin Multiplatform #411 Publish artifacts to be used with kotlinc command line #490 KspTask does not support gradle remote cache #240 java.lang.IllegalStateException: Cannot find descriptor for values #439 NPE #518 Configuration on demand does not work with KSP #540 Publish KSP on Maven Central? Please give it a try and let us know any thoughts!
    🎉 17
    n
    t
    a
    • 4
    • 17
  • u

    Udi Cohen

    08/13/2021, 10:14 PM
    Hi, I'm trying to use the new
    symbol-processing-cmdline
    artifact to use KSP from the command line, but I'm getting a classpath related exception so I wanted to verify the command I'm using is correct. I downloaded all the beta7 artifacts and the playground project, and I'm using the following command:
    kotlinc -cp /Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar:/Users/udinic/tmp/ksp-stuff/bug/playground/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar \
    -Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-cmdline-1.5.21-1.0.0-beta07.jar \
    -P plugin:com.google.devtools.ksp.symbol-processing:apclasspath=/Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar \
    -P plugin:com.google.devtools.ksp.symbol-processing:projectBaseDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/src \
    -P plugin:com.google.devtools.ksp.symbol-processing:classOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/classes/kotlin/main \
    -P plugin:com.google.devtools.ksp.symbol-processing:kotlinOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/kotlin \
    -P plugin:com.google.devtools.ksp.symbol-processing:javaOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/java \
    -P plugin:com.google.devtools.ksp.symbol-processing:resourceOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/resources \
    -P plugin:com.google.devtools.ksp.symbol-processing:cachesDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/cache \
    -P plugin:com.google.devtools.ksp.symbol-processing:kspOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/ksp \
    /Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/kotlin/ /Users/udinic/tmp/ksp-stuff/bug/playground/workload/src/
    But I'm getting an exception:
    exception: java.lang.NoClassDefFoundError: com/google/devtools/ksp/processing/KSPLogger
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    	at com.google.devtools.ksp.KotlinSymbolProcessingComponentRegistrar.registerProjectComponents(KotlinSymbolProcessingPlugin.kt:90)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:609)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:130)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:170)
    ....
    This class is part of the
    symbol-processing-api
    artifact that I already included in the plugin's classpath. Is there something I'm missing here? I tried adding all the relevant symbol-processing articats into the kotlinc classpath and the plugin's classpath - still doesn't work :/
    t
    • 2
    • 5
Powered by Linen
Title
u

Udi Cohen

08/13/2021, 10:14 PM
Hi, I'm trying to use the new
symbol-processing-cmdline
artifact to use KSP from the command line, but I'm getting a classpath related exception so I wanted to verify the command I'm using is correct. I downloaded all the beta7 artifacts and the playground project, and I'm using the following command:
kotlinc -cp /Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar:/Users/udinic/tmp/ksp-stuff/bug/playground/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar \
-Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-cmdline-1.5.21-1.0.0-beta07.jar \
-P plugin:com.google.devtools.ksp.symbol-processing:apclasspath=/Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar \
-P plugin:com.google.devtools.ksp.symbol-processing:projectBaseDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/src \
-P plugin:com.google.devtools.ksp.symbol-processing:classOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/classes/kotlin/main \
-P plugin:com.google.devtools.ksp.symbol-processing:kotlinOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/kotlin \
-P plugin:com.google.devtools.ksp.symbol-processing:javaOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/java \
-P plugin:com.google.devtools.ksp.symbol-processing:resourceOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/resources \
-P plugin:com.google.devtools.ksp.symbol-processing:cachesDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/cache \
-P plugin:com.google.devtools.ksp.symbol-processing:kspOutputDir=/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/ksp \
/Users/udinic/tmp/ksp-stuff/bug/playground/workload/build2/generated/ksp/main/kotlin/ /Users/udinic/tmp/ksp-stuff/bug/playground/workload/src/
But I'm getting an exception:
exception: java.lang.NoClassDefFoundError: com/google/devtools/ksp/processing/KSPLogger
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at com.google.devtools.ksp.KotlinSymbolProcessingComponentRegistrar.registerProjectComponents(KotlinSymbolProcessingPlugin.kt:90)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:609)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:130)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:170)
....
This class is part of the
symbol-processing-api
artifact that I already included in the plugin's classpath. Is there something I'm missing here? I tried adding all the relevant symbol-processing articats into the kotlinc classpath and the plugin's classpath - still doesn't work :/
t

Ting-Yuan Huang

08/13/2021, 11:12 PM
Have you tried adding
-Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar
?
BTW, although not contributing to this exception/stacktrace,
apclasspath
should be set to the processor. and the compiler classpath
-cp
shouldn't be needed.
i.e.,
-P plugin:com.google.devtools.ksp.symbol-processing:apclasspath=/Users/udinic/tmp/ksp-stuff/bug/playground/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar
u

Udi Cohen

08/13/2021, 11:26 PM
Cool that did the trick! Thanks for the prompt reply. Maybe it's a good idea to put a sample command in one of the READMEs. As a reference, here's the full command that's working for me now:
kotlinc -cp /Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar:/Users/udinic/projects/ksp-playground4/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar \
-Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar \
-Xplugin=/Users/udinic/tmp/ksp-stuff/symbol-processing-cmdline-1.5.21-1.0.0-beta07.jar \
-P plugin:com.google.devtools.ksp.symbol-processing:apclasspath=/Users/udinic/tmp/ksp-stuff/bug/playground/test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar:/Users/udinic/tmp/ksp-stuff/symbol-processing-api-1.5.21-1.0.0-beta07.jar \
-P plugin:com.google.devtools.ksp.symbol-processing:projectBaseDir=/Users/udinic/projects/ksp-playground4/workload/src/main/java \
-P plugin:com.google.devtools.ksp.symbol-processing:classOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/classes/kotlin/main \
-P plugin:com.google.devtools.ksp.symbol-processing:kotlinOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/kotlin \
-P plugin:com.google.devtools.ksp.symbol-processing:javaOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/java \
-P plugin:com.google.devtools.ksp.symbol-processing:resourceOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/resources \
-P plugin:com.google.devtools.ksp.symbol-processing:cachesDir=/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/cache \
-P plugin:com.google.devtools.ksp.symbol-processing:kspOutputDir=/Users/udinic/projects/ksp-playground4/workload/build2/ksp \
/Users/udinic/projects/ksp-playground4/workload/build2/generated/ksp/main/kotlin/ /Users/udinic/projects/ksp-playground4/workload/src/main/java
I built the
test-processor
module using gradle so far, but now I'll check how to use command line for this too.
t

Ting-Yuan Huang

08/13/2021, 11:27 PM
Will update the docs. Thanks for trying it out 😄
View count: 6