Skip to content

[KSP2] getDeclarationsFromPackage has a different output when compare with ksp1 #2396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
oscarthecat opened this issue Mar 31, 2025 · 4 comments
Labels
AA waiting for upstream fix
Milestone

Comments

@oscarthecat
Copy link

oscarthecat commented Mar 31, 2025

kotlin 2.1.10
ksp 2.1.10-1.0.30

we have a simple kmp workload module depends on another kmp module lib1, in lib1 we have a kkkk.kt which is quite simple like this

package com.kkkk
class K1 {
    val k1 = "k1"
}
class K2 {
    val k2 = "k2"
}

now we try to apply a test-processor to workload module, in test-processor we have

    @OptIn(KspExperimental::class)
    override fun process(resolver: Resolver): List<KSAnnotated> {
        val kkkk = resolver.getDeclarationsFromPackage("com.kkkk").toList()

we log kkkk content and expect to see [K2, K1], and run

./gradlew :workload:kspKotlinJvm
./gradlew :workload:kspKotlinIosX6
./gradlew :workload:kspCommonMainKotlinMetadata

with both enable and disable ksp2

when there is no ksp.useKSP2=true, both three gradle tasks output [K2, K1]
when add ksp.useKSP2=true, only ./gradlew :workload:kspKotlinJvm output [K2, K1], but ./gradlew :workload:kspKotlinIosX6 ./gradlew :workload:kspCommonMainKotlinMetadata returns empty. We also tried without gradle but just command lines, and get the same result.

Any way to get declarations from other module (like klib1) for all gradle tasks? Or some settings we can add in build.gradle? Thanks a lot.

@ting-yuan
Copy link
Collaborator

Sounds like a bug to me. Can you share a small project that I can reproduce this problem?

@oscarthecat
Copy link
Author

multiplatform.zip Copied from the example multiplatform project, pls and thanks

@ting-yuan ting-yuan added this to the 2.0.1 milestone Apr 9, 2025
@ting-yuan
Copy link
Collaborator

Multiplatform support of this is currently missing in the Kotlin Analysis API. We're working with JetBrains on it and it will take a bit longer.

@ting-yuan ting-yuan added the AA waiting for upstream fix label Apr 24, 2025
@ting-yuan ting-yuan modified the milestones: 2.0.1, 2.0.2 Apr 30, 2025
@lppedd
Copy link

lppedd commented May 24, 2025

@ting-yuan did you want to link something else via missing above? It links to this issue currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AA waiting for upstream fix
Projects
None yet
Development

No branches or pull requests

3 participants