Vladimir Tagakov
08/03/2022, 7:10 AM//Module A
public class MyJavaClass {
public @interface MyAnnotation {}
}
//Module B with KSP Processor
class MyKotlinClass(@MyJavaClass.MyAnnotation val myProp: Any)
Hi! In my KSP Processor I’m trying to resolve KSTypeReference
of annotation type MyJavaClass.MyAnnotation
which I face during analysis of `MyKotlinClass`’s constructor and for some reason it could not be resolved (KSType#isError
returns true).
If I move MyAnnotation
to the top-level everything works fine.
I am not sure how I can debug this issue, any ideas? =\Vaios Tsitsonis
08/04/2022, 9:24 AMjuliocbcotta
08/04/2022, 9:34 AMStylianos Gakis
08/04/2022, 12:18 PM:kspProcessors
inside the project, and I am importing it into my module (let’s call it :app
) where I want the code generated with add("kspJs", project(":kspProcessors"))
, add("kspAndroid", project(":kspProcessors"))
and add("kspIosX64", project(":kspProcessors"))
.
Thing is, inside my KSP, code, it’d be very convenient to have access to the classes that exist inside my :app
module, to more easily reference them in the code I generate. But would I not then introduce a circular dependency if :kspProcessors
was depending on :app
with implementation(project(":app"))
and had :app
depend on the ksp module as I am describing above?
Would I need to keep the KSP code inside the same module? Maybe there’s no circular dep if one depends on the other using implementation
and the other using ksp
? I do not know if I am wording my question as well as I could’ve since I am totally not familiar with how to work with KSP in general, so please ask clarifying questions if I can make something more understandable.Stylianos Gakis
08/04/2022, 4:17 PMannotation class ComposeRenderer(
val forComponent: KClass<out Component>,
)
I can’t figure out if it’s be possible to get in some way what the KClass would be to get it’s name, package and if it has any generics, and I am having a hard time looking into the documentation myself in order to help myself basically. And the questions existing online on SOF or whatever are quite sparse for KSP. Is there some place where people tend to go when they have KSP questions that I should be aware of?Ovsyannikov Alexey
08/05/2022, 7:25 AMKSCLassDeclaration
in case if that declaration is no sealed?Joost Klitsie
08/08/2022, 9:13 AMroom-compiler-processing-2.4.3.jar (pkg:maven/androidx.room/room-compiler-processing@2.4.3, cpe:2.3:a:processing:processing:2.4.3:*:*:*:*:*:*:*) : CVE-2018-1000840
symbol-processing-1.7.10-1.0.6.jar (pkg:maven/com.google.devtools.ksp/symbol-processing@1.7.10-1.0.6, cpe:2.3:a:processing:processing:1.7.10.1:*:*:*:*:*:*:*) : CVE-2018-1000840
symbol-processing-api-1.7.10-1.0.6.jar (pkg:maven/com.google.devtools.ksp/symbol-processing-api@1.7.10-1.0.6, cpe:2.3:a:processing:processing:1.7.10.1:*:*:*:*:*:*:*) : CVE-2018-1000840
Am I correct that we can safely ignore this? I assume the generated code will not be affected by this. (we are building an Android application so we care mostly about runtime safety)Slackbot
08/11/2022, 1:59 PMSrSouza
08/11/2022, 9:18 PMjean
08/12/2022, 9:24 AMMichal Klimczak
08/14/2022, 3:15 PMZac Sweers
08/16/2022, 8:15 PMfile or directory '/Users/zacsweers/dev/slack/slack-android-ng/app/build/generated/ksp/internalDebugAndroidTest/classes', not found
Transforming core-for-system-modules.jar with JdkImageTransform
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
Compiling with toolchain '/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home'.
file or directory '/Users/zacsweers/dev/slack/slack-android-ng/app/src/androidTestDebug/java', not found
file or directory '/Users/zacsweers/dev/slack/slack-android-ng/app/build/generated/ksp/internalDebugAndroidTest/java', not found
file or directory '/Users/zacsweers/dev/slack/slack-android-ng/app/build/generated/ksp/internalDebugAndroidTest/java', not found
Aditya Kurkure
08/18/2022, 8:31 AMkspcache
however it works perfectly fine on the first run when the classes are located at build>generated>ksp
any idea why this happens and what the fix might be?Jintin
08/23/2022, 12:57 AMGrégory Lureau
08/25/2022, 10:00 AMcompileTestKotlinJs
it somehow triggers the task kspReleaseUnitTestKotlinAndroid
.
Any idea why it's linked? Is it an expected behavior?jean
08/25/2022, 7:55 PMreturn (argument as Array<KClass<*>>)
.toList()
.all {
resolver.getClassDeclarationByName(it::class.java.simpleName)
?.filterAnnotations<CrossViewEvent>()
?.toList()
?.isNotEmpty() ?: false
}
is it possible to convert a KClass
to a KSType
without using the resolver?PHondogo
08/25/2022, 9:03 PMJi Sungbin
08/29/2022, 1:09 AMjava.io.File
package)Vladimir Tagakov
08/29/2022, 10:26 PMClass<?>
argument. And for some reason for one class KSP resolves class type passed to the argument successfully and for another class KSP returns ERROR TYPE. It looks super weird since both annotated classes very similar, both have the same visibility and implement same interfaces. The only difference is the package. Class passed to a Class<?>
argument in both cases is being nested inside annotated class itself. I’m confused and not sure how to even approach debugging here =\Shreyash Saitwal
09/01/2022, 4:48 PMjuliocbcotta
09/05/2022, 2:52 PMjuliocbcotta
09/08/2022, 10:41 AMOdin
09/10/2022, 6:47 PMXRoundEnv.getElementAnnotatedBy
if I know the qualifiedName of the annotation in question. However, if I use the typeName of the annotation that I get from XRoundEnv.getElementAnnotatedBy
to fetch the annotation that the first annotation is annotated with, it only works if they are in the same module. Does anyone know if this is possible? 😄 Is it not working because I use the typeName form the first annotation?evant
09/13/2022, 12:12 AMdeclaration.getAllFunctions()
is not picking up functions though a type generated in a previous round, ie: If I have:
interface Source { fun targetFun() {} }
interface Generated : Source // this is generated in round 1
interface Target : Generated // this is processed in round 2
then
declaration.getAllFunctions()
won't include targetFun()
interestingly enough walking up to the interface manually does work
((declaration.superTypes.first().resolve().declaration as KSClassDeclaration).superTypes.first().resolve().declaration as KSClassDeclaration).getDeclaredFunctions()
TheDukerChip
09/13/2022, 4:19 AMUnknownPluginException
for KSP
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.devtools.ksp', version: '1.7.10-1.0.6'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.7.10-1.0.6')
Following is the configuration added in my android project app/build.gradle
plugins {
id("com.android.application")
id("kotlin-android")
id 'com.google.devtools.ksp' version("1.7.10-1.0.6")
}
dependencies {
"""
def room_version = "2.4.3"
implementation "androidx.room:room-runtime:$room_version"
ksp "androidx.room:room-compiler:$room_version"
}
Simon
09/13/2022, 3:45 PMKSClassDeclaration
, KSFunctionDeclaration
and KSPropertyDeclaration
. Do you know whether there is a plan to also support annotations with @Target(AnnotationTarget.EXPRESSION)
? Thanks!Vladimir Tagakov
09/14/2022, 8:40 PMcom.google.devtools.ksp.UtilsKt#isVisibleFrom
. When it looks at protected visibility it treats it as visible if it is in the same package with a class passed to isVisibleFrom
it works for java but doesn’t work for kotlin, because in kotlin protected is only accessible from the class inheritors.spierce7
09/22/2022, 1:24 PMChristopher Porto
09/23/2022, 11:38 PMjean
09/24/2022, 8:27 AMsourceSets.commonMain {
kotlin.srcDir("$buildDir/generated/ksp/commonMain/kotlin/")
}
sourceSets.commonTest {
kotlin.srcDir("$buildDir/generated/ksp/commonMain/kotlin/")
}
But I still get a Source file or directory not found
. What should I do to fix that?jean
09/24/2022, 8:27 AMsourceSets.commonMain {
kotlin.srcDir("$buildDir/generated/ksp/commonMain/kotlin/")
}
sourceSets.commonTest {
kotlin.srcDir("$buildDir/generated/ksp/commonMain/kotlin/")
}
But I still get a Source file or directory not found
. What should I do to fix that?$buildDir
with build
, I then get this
Task :example:linkDebugTestIosX64 FAILED
...
Compilation failed: IrClassPublicSymbolImpl for com.jeantuffier.statemachine/MyClass|null[0] is already bound: CLASS CLASS MyClass modality:SEALED visibility:public superTypes:[kotlin.Any]
* Source files:
* Compiler version info: Konan: 1.7.10 / Kotlin: 1.7.20
* Output kind: PROGRAM
Ting-Yuan Huang
09/29/2022, 4:40 PMResolver.getClassDeclarationByName
returns the compiled classes.jean
09/29/2022, 6:26 PM