Skip to content

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

Open
@oscarthecat

Description

@oscarthecat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AAwaiting for upstream fix

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions