Skip to content

Order KSP tasks after the Protobuf code generation - #838

Merged
alexander-yevsyukov merged 2 commits into
masterfrom
ksp-after-generate-proto
Nov 5, 2026
Merged

alexander-yevsyukov merged 2 commits into
masterfrom
ksp-after-generate-proto

Conversation

@alexander-yevsyukov

Copy link
Copy Markdown
Contributor

What

Project.configureTaskDependencies() now orders the KSP tasks after the Protobuf code generation:

  • kspKotlin → generateProto
  • kspTestKotlin → generateTestProto
  • kspTestFixturesKotlin → generateTestFixturesProto

The edges use the function's local String.dependOn(taskName) helper, so they are lazy and do nothing in a module that lacks either task. They sit next to the existing compileKotlin → generateProto wiring.

The test-fixtures edge has no current failure behind it. The only consumer modules with test-fixture protos and KSP use the Spine Compiler, which already orders KSP. It is included because configureTaskDependencies() already wires kspTestFixturesKotlin, and the cause is the same for every source set.

Why

KSP reads the sources that the Protobuf tasks generate. In a module that applies both protobuf and KSP, nothing ordered KSP after generateProto, so Gradle failed the build on an implicit dependency. This came up in the scoped refresh wave closed by #836: base-libraries had to add the wiring by hand in base/build.gradle.kts (SpineEventEngine/base-libraries#969).

In modules that use the Spine Compiler, the new edge changes nothing. The Compiler plugin already makes kspX depend on its launch task, and that task depends on generateXProto. Nothing makes generateProto depend on KSP or on the Compiler, so the new edge cannot create a cycle.

Consumer follow-up

After their next ./config/pull:

  • base-libraries can drop its local copy (the mapOf("kspKotlin" to "generateProto", …) block in base/build.gradle.kts).
  • validation has no copy of this wiring to drop. Its two local blocks wire KSP against launchSpineCompiler, not generateProto:
    • context/build.gradle.kts (kspKotlin → launchSpineCompiler) is already redundant, because the Spine Compiler plugin adds that edge itself.
    • tests/validator/build.gradle.kts adds the opposite edge (launchSpineCompiler → kspKotlin), because the Compiler consumes KSP output there. This change does not affect it.

Tests

BuildExtensionsSpec gets a new group with three ProjectBuilder tests:

  • all three edges are added;
  • KSP tasks registered after evaluation still get the edges;
  • nothing is added when the project has no Protobuf tasks.

Against master's BuildExtensions.kt, the first two fail.

🤖 Generated with Claude Code

`configureTaskDependencies()` now makes each KSP task depend on the
Protobuf task of its source set: `kspKotlin` on `generateProto`,
`kspTestKotlin` on `generateTestProto`, and `kspTestFixturesKotlin`
on `generateTestFixturesProto`. KSP reads the sources that the Protobuf
tasks generate, so a module that applies both plugins without the Spine
Compiler failed Gradle's implicit-dependency check. The Spine Compiler
already orders KSP after its launch task, which itself runs after
`generateProto`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexander-yevsyukov alexander-yevsyukov self-assigned this Nov 5, 2026
@alexander-yevsyukov alexander-yevsyukov moved this to In Review in v2.0 Nov 5, 2026
@alexander-yevsyukov
alexander-yevsyukov marked this pull request as ready for review November 5, 2026 20:06
Copilot AI balanced review requested due to automatic review settings November 5, 2026 20:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T20:08:29.644826Z 34a9ad0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The shared KSP-to-Protobuf task dependency change has no active review issues blocking approval.

No open issues 🎉

What changed in this PR

Ensures KSP runs after Protobuf source generation through the shared Gradle task-dependency configuration, removing the need for equivalent wiring in consumer modules.

Changes:

  • Adds lazy dependencies for main, test, and test-fixtures KSP tasks on their corresponding Protobuf generation tasks.
  • Adds tests covering all three dependencies, task registration after evaluation, and projects without Protobuf tasks.
File Description
buildSrc/​src/​test/​kotlin/​BuildExtensionsSpec.kt Tests KSP-to-Protobuf dependencies and optional-task behavior.
buildSrc/​src/​main/​kotlin/​BuildExtensions.kt Adds the three dependencies and reuses KSP task-name variables.

Review effort: Balanced

@alexander-yevsyukov
alexander-yevsyukov merged commit 122d3f4 into master Nov 5, 2026
2 checks passed
@alexander-yevsyukov
alexander-yevsyukov deleted the ksp-after-generate-proto branch November 5, 2026 20:10
@github-project-automation github-project-automation Bot moved this from In Review to ✅ Done in v2.0 Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants