[AGP] Register generated kotlin sources with java source set - #2707
Merged
Conversation
hfmehmed
force-pushed
the
agp-generated-kotlin-sources
branch
2 times, most recently
from
November 21, 2025 20:54
a5e0e76 to
8a0e947
Compare
hfmehmed
force-pushed
the
agp-generated-kotlin-sources
branch
from
November 24, 2025 14:41
8a0e947 to
7fda891
Compare
cmwarrington
approved these changes
Nov 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intially we registered java output folder with java sourceset and kotlin output folder with kotlin sourceset. Two reasons for this:
Number 2 is fixed in AGP 9.0.0-alpha14.
However, it turns out number 1 is problematic. Registering with kotlin sourceset ends up in a circular task dependency with built in kotlin feature enabled.
At the moment, we avoid the circular exception because we look at all the task dependencies of the kotlin sourceset and exclude the ksp task. But this is a project isolation breaking logic which we need to remove at some point.
The flow looks like the following more or less:
KSP task -> register kotlin output with kotlin.sources -> kotlin.sources flows into kotlinCompilation.defaultSourceSet.kotlin.srcDirs() this happens in AGP built in kotlin -> kotlin.srcDirs() is an input to ksp task leading to the circularlity.