Skip to content

Configuration kspWebMainMetadata missing #2814

Open

Description

@mallumoSK

In project are declared
targets: JS, WasmJS
sourceSets: commonMain, webMain

Gradle tasks are correct:

kspCommonMainKotlinMetadata
kspKotlinJs
kspKotlinWasmJs
kspTestKotlinJs
kspTestKotlinWasmJs
kspWebMainKotlinMetadata

But in configurations are:

ksp
kspCommonMainMetadata
kspJs
kspJsTest
kspWasmJs
kspWasmJsTest

-> kspWebMainMetadata is missing

I found only one way how to use task "kspWebMainKotlinMetadata" as:

dependencies {
  add("ksp", projects.customKspPlugin)
}

With this configurations after execution of gradle task kspWebMainKotlinMetadata are generated

  • build/generated/ksp/metadata/commonMain
  • build/generated/ksp/metadata/webMain

There happened next problem:

build/generated/ksp/metadata/webMain is combination of sourceSets commonMain and webMain.
I mean duplicity of commonMain.

Expected behavior

Existence kspWebMainMetadata configuration.
Then configutaion of:

dependencies {
  add("kspWebMainMetadata", projects.customKspPlugin)
}

will be generated only build/generated/ksp/metadata/webMain from only sourceSet of webMain

OR:

dependencies {
  add("kspWebMain", projects.customKspPlugin)
}

will generate build/generated/ksp/webMain as combination of webMain + its parrents, in this case commonMain

Activity

  1. added
    P3
    Gradle
    on Jul 2, 2026
  2. hfmehmed commented on Sep 22, 2026

    @hfmehmed
    Collaborator

    Thanks for this report. I think the configuration is not missing but to me it seems like it is created only once KGP creates the compilation for the shared "webMain" source set which likely happens after your build script has run. In KSP we derive these configuration from compilation rather than source set (possible regretably?) and the compilation for the shared source set are not eagerly created.

    So i think as a workaround you can do

    configurations.configureEach {
        if (name == "kspWebMainMetadata") {
            dependencies.add(project.dependencies.create(...))
        }
    }
    

    And i will look into a more long term solution so you dont need hacky workarounds like that.

    The second issue you mentioned (webMain generated output containing the commonMain output) is truly surprising to me too. I am looking at that as well (it is possibly a separate issue but lets track it here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GradleP3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions