-
Notifications
You must be signed in to change notification settings - Fork 274
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
Adding KSP dependencies in Project.afterEvaluate
results in KSP tasks not being registered
#1524
Comments
KSP creates tasks when it is called by Kotlin Gradle Plugin in the middle of configuration phase. If I defer the task creation (if possible; there seems to be no reliable way to enforce configuration order for loosely coupled components), it'll likely break scripts / plugins that modify or read attributs of KSP's tasks. May I learn more about your use case where the dependency has to be added in the end of configuration? |
My use case is a gradle plugin that hosts a compiler plugin and enables KSP as-needed. Here's the impl: https://github.com/ZacSweers/MoshiX/blob/main/moshi-ir/moshi-gradle-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/gradle/MoshiGradleSubplugin.kt |
KSP checks the configuration here which is called indirectly in an Listening to dependency changes in KSP might work, but it would also require some significant changes. I'd consider this as a new feature instead of a bug and therefore it'll need to wait until the K2 migration is done. Or any thoughts on simpler solutions? |
I have pretty much the same issue as described above! I apply ksp plugin immediately on applyProject as a fix for now. |
We sometimes have plugins that defer configuration until after buildscripts are evaluated to get a correct picture of the the project's setup. If we defer adding KSP dependencies until this, it appears that KSP's gradle plugin will end up incorrectly never registering KSP tasks if they're not added directly in the buildscript.
Example build file
The above will fail to register any KSP tasks even though a KSP processor dep was added eventually
The text was updated successfully, but these errors were encountered: