Skip to content
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

KSP task (non-)registration happens too soon #1789

Open
ZacSweers opened this issue Mar 11, 2024 · 1 comment
Open

KSP task (non-)registration happens too soon #1789

ZacSweers opened this issue Mar 11, 2024 · 1 comment

Comments

@ZacSweers
Copy link
Contributor

ZacSweers commented Mar 11, 2024

I have a gradle plugin that tries to conditionally enable KSP and add relevant KSP processors to it. However, I found that KSP's task registration can be unintentionally deleted by a simple project.afterEvaluate in gradle, resulting in the task never being registered and thus not run.

Example

// in build.gradle.kts, or a gradle plugin

project.afterEvaluate {
  if (enableKsp) {
    pluginManager.apply("com.google.devtools.ksp")

    dependencies.add("ksp", "some.ksp:processor:1.0.0")
  }
}

will result in KSP being applied but no ksp*Kotlin task ever being registered and thus never running. If I add any dependency to the ksp configuration (even one without any KSP processors in it), it works and picks up the later-added dependency too.

I think I would expect this to always register the KSP task, then conditionally no-op at task-action-time rather than try to conditionally avoid adding the task.

@ZacSweers
Copy link
Contributor Author

Sorry it looks like this is actually after two afterEvaluate calls, not just one level. Which is admittedly a somewhat edge case :). That said, still would be nice if there was a way to defer this to task-time instead

Enaium added a commit to Enaium-Fork/ksp that referenced this issue Apr 30, 2024
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

No branches or pull requests

1 participant