Skip to content

Register generated ksp output for Android KMP plugin#2777

Merged
hfmehmed merged 2 commits into
google:mainfrom
hfmehmed:kmp-register-generated-output
Feb 11, 2026
Merged

Register generated ksp output for Android KMP plugin#2777
hfmehmed merged 2 commits into
google:mainfrom
hfmehmed:kmp-register-generated-output

Conversation

@hfmehmed

@hfmehmed hfmehmed commented Feb 8, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2744
And errors such as

Reason: Task ':extra:settings:api:extractAndroidMainAnnotations' uses this output of task ':extra:settings:api:kspAndroidMain' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Possible solutions:
1. Declare task ':extra:settings:api:kspAndroidMain' as an input of ':extra:settings:api:extractAndroidMainAnnotations'.
2. Declare an explicit dependency on ':extra:settings:api:kspAndroidMain' from ':extra:settings:api:extractAndroidMainAnnotations' using Task#dependsOn.
3. Declare an explicit dependency on ':extra:settings:api:kspAndroidMain' from ':extra:settings:api:extractAndroidMainAnnotations' using Task#mustRunAfter.

For more information, please refer to https://docs.gradle.org/9.2.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

when using the new Android-kmp plugin, which previously required manual workaround like

tasks.named { it == "kspAndroidMain" }.configureEach {
    dependsOn(tasks.named("extractAndroidMainAnnotations"))
}

afterEvaluate is needed to ensure that the Variant API callback is executed when we retrieve the Component object from the cache.

@hfmehmed hfmehmed force-pushed the kmp-register-generated-output branch from f19c65c to 946a92a Compare February 8, 2026 17:51
@hfmehmed hfmehmed force-pushed the kmp-register-generated-output branch 2 times, most recently from 73461a7 to 5068910 Compare February 9, 2026 21:35
Comment thread gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt Outdated
@hfmehmed hfmehmed force-pushed the kmp-register-generated-output branch from 5068910 to f1803b9 Compare February 10, 2026 08:19
@hfmehmed hfmehmed merged commit dc08add into google:main Feb 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android KMP + KSP on IP-compatible path ignores generated java sources

2 participants