-
Notifications
You must be signed in to change notification settings - Fork 350
Re-enable support for AGP + built in kotlin in KSP #2624
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
base: main
Are you sure you want to change the base?
Conversation
Experimenting with reading AGP static and generated sources using sources.kotlin but regirested KSP generated sources to java sources to avoid circular dependency
|
||
kspTaskProvider.configure { task -> | ||
when (task) { | ||
is KspTaskJvm -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is / should this ever reachable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose technically you can use builtin kotlin and ksp1
but maybe we should restrict that it never reaches it since ksp1 is deprecated and we dont thoroughly test it
val dir = destinationProperty?.get()?.asFile | ||
sources.filter { dir?.isParentOf(it.dir) != true } | ||
if (project.isAgpBuiltInKotlinUsed() && androidComponent != null) { | ||
val sources = androidComponent.sources.kotlin?.all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the first attempt was androidComponent.sources.java.static
. Are they the same set of files? In other words, would this approach miss any desired files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sources.kotlin
contains everything that java.static has and more stuff that are generated by AGP such as databinding and build config.
The benefit of using sources.kotlin.all
is also that it doesnt contain the ksp output (hence not leading to circular dependency)
I found another use where this does not work. So holding off of merging this until we untangle that |
In order to enable built in kotlin we need to able to read AGP (static + generated such as databinding/buildconfig) sources using the new variant api.
Initial approach was to read "sources.java.all". While this contains everything needed it also contained kapt output directory as well as ksp output directory (because of sources.java.addGeneratedSourceDirectory() registeration for purposes of IDE symbol resolution)
Using "sources.kotlin.all" is a better alternative as it still contains all the static and generated sources but it doesnt contains kapt and ksp output which fixes the circular dependency problem.