Skip to content

Arrange LaunchSpineCompiler state at configuration time#81

Merged
alexander-yevsyukov merged 4 commits into
masterfrom
fix-launch-task-exec-time-config
Jul 11, 2026
Merged

Arrange LaunchSpineCompiler state at configuration time#81
alexander-yevsyukov merged 4 commits into
masterfrom
fix-launch-task-exec-time-config

Conversation

@alexander-yevsyukov

Copy link
Copy Markdown
Contributor

What

Eliminates two Gradle deprecation warnings that consumer builds (observed in delivery-server on Gradle 9.6.1) receive from every executed launchSpineCompiler task:

  • "Changing property value of task ':…:launchSpineCompiler' property 'mainClass' at execution time" — becomes an error in Gradle 11;
  • "Invocation of Task.dependsOn at execution time" — becomes an error in Gradle 10 and is incompatible with the configuration cache.

How

All task state is now arranged at configuration time:

  • The constant mainClass is set in the task init block.
  • The classpath (two lazy Configurations) is added in applyDefaults().
  • The --params <file> pair is registered via argumentProviders, so it is evaluated only when the command line is built and — as before — the absolute path stays out of the build-cache key, keeping cached outputs relocatable.
  • A new protoSourceDirs: ConfigurableFileCollection property, wired by consumeProtoFrom() from handleLaunchTaskDependency(), replaces the execution-time dependsOn.first { it is GenerateProtoTask } traversal.
  • compileCommandLine() is deleted; a name-collision on the reserved task name now fails fast with a curated check message instead of a silent misconfiguration.

Deliberately unchanged: writing the parameters file stays a doFirst action. Serializing PipelineParameters loads Spine KnownTypes through the thread context classloader, which Gradle sets to the plugin classloader only around doFirst/doLast actions — from the @TaskAction method the desc.ref lookup fails. The constraint is documented at the call site. A file write is a side effect, not task-state mutation, so it triggers no deprecation.

Verification

  • Full ./gradlew build dokkaGenerate is green.
  • A new functional test (PluginSpec."not mutate the launch task state at execution time") runs a consumer fixture with --warning-mode=all and asserts both messages are absent.
  • The test's sensitivity is proven by an A/B run of a standalone consumer project on Gradle 9.6.1: plugin 2.0.0-SNAPSHOT.060 (pre-fix) emits both warnings exactly once each; this branch's plugin emits none, with the launch task executing in both runs.
  • Pre-PR checklist passed: version gate (2.0.0-SNAPSHOT.061 → .062 with regenerated dependency reports), spine-code-review, kotlin-engineer, and review-docs reviewers (all feedback applied).

🤖 Generated with Claude Code

alexander-yevsyukov and others added 3 commits July 10, 2026 19:03
Gradle 9.6 deprecates mutating task state at execution time, and the
deprecations become hard errors in Gradle 10/11. The launch task used
to assemble its CLI command, including the `mainClass` property, in
a `doFirst` action, and to query `Task.dependsOn` while writing the
parameters file. Consumer builds saw two warnings in problem reports:

 - "Changing property value of task ':launchSpineCompiler' property
   'mainClass' at execution time" (an error starting with Gradle 11);
 - "Invocation of Task.dependsOn at execution time" (an error starting
   with Gradle 10, incompatible with the configuration cache).

Now the `init` block sets the constant `mainClass`, `applyDefaults()`
adds the classpath and registers the `--params <file>` pair via
`argumentProviders` — keeping the absolute path out of the build-cache
key, as before — and the new `protoSourceDirs` property, wired by
`consumeProtoFrom()` from `handleLaunchTaskDependency()`, replaces
the `dependsOn` traversal.

Writing the parameters file deliberately stays a `doFirst` action:
serializing `PipelineParameters` loads Spine `KnownTypes` via the
thread context classloader, which Gradle sets to the plugin classloader
only around `doFirst`/`doLast` actions. A file-system side effect is
not a task-state mutation, so no deprecation is triggered.

A new functional test runs a consumer fixture with `--warning-mode=all`
and locks the absence of both warnings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Also commit the regenerated dependency reports.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
 - Reuse `createLaunchTestProject()` in the deprecation regression test
   instead of duplicating the fixture name.
 - Clarify KDoc wording flagged by the documentation review.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 18:23

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.

Pull request overview

This PR updates the Spine Compiler Gradle plugin to avoid Gradle 9.6+ “execution-time mutation” deprecations by moving LaunchSpineCompiler task state setup fully into configuration time, keeping the task compatible with configuration cache and upcoming Gradle 10/11 behavior.

Changes:

  • Configure LaunchSpineCompiler’s constant mainClass, classpath, and CLI --params <file> argument at configuration time (using argumentProviders) and remove the execution-time command-line assembly.
  • Replace execution-time dependsOn traversal with an explicit protoSourceDirs carrier populated via consumeProtoFrom(generateProto), and fail fast on reserved task-name collisions.
  • Add a functional regression test asserting the deprecation warnings are absent under --warning-mode=all, plus version/report bumps.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
version.gradle.kts Bumps the compiler version snapshot used by builds/tests.
gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Plugin.kt Wires GenerateProtoTaskLaunchSpineCompiler relationship via consumeProtoFrom() and adds a guarded fast-fail for task-name collisions.
gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt Moves task state setup to configuration time; introduces protoSourceDirs and argumentProviders; removes execution-time command-line mutation.
gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/PluginSpec.kt Adds a functional test ensuring Gradle deprecation warnings are not emitted.
docs/dependencies/pom.xml Updates docs dependency metadata version to the new snapshot.
docs/dependencies/dependencies.md Regenerates dependency report for the new snapshot/version.
.agents/tasks/fix-launch-task-exec-time-config.md Adds an agent task log/plan document (non-functional project metadata).

@alexander-yevsyukov alexander-yevsyukov moved this to 🏗 In progress in v2.0 Jul 10, 2026
@alexander-yevsyukov alexander-yevsyukov self-assigned this Jul 10, 2026
CI failed on `Build on Ubuntu` and the performance smoke test with
`io.spine.type.UnknownTypeException` after restoring `known_types`
descriptor sets `FROM-CACHE`. This is the descriptor-set build-cache
bug documented in PR #80: the descriptor file name embeds the Maven
version, but the name was not part of the task cache key, so the
version bump in this branch made CI restore the stale entry cached
by the `.061` build.

The fix shipped with ToolBase 2.0.0-SNAPSHOT.403 reaches a consumer
build only through the Compiler pin on its buildscript classpath, and
this repository is such a consumer via dogfooding: the bootstrap pin
`2.0.0-SNAPSHOT.059` predates the fix. Advance `fallbackVersion` and
`fallbackDfVersion` to `2.0.0-SNAPSHOT.061`, built from `master` with
ToolBase `.403`. The new plugin classpath also changes the classloader
hash of the proto-generating tasks, so CI takes cache misses instead
of the poisoned entries.

Also commit the dependency reports regenerated with the new pin.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 18:40

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@alexander-yevsyukov alexander-yevsyukov moved this from 🏗 In progress to In Review in v2.0 Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.87%. Comparing base (eeceb4b) to head (a4ab3b2).

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #81      +/-   ##
============================================
+ Coverage     76.60%   76.87%   +0.27%     
- Complexity      687      688       +1     
============================================
  Files           205      205              
  Lines          4018     4026       +8     
  Branches        400      402       +2     
============================================
+ Hits           3078     3095      +17     
+ Misses          810      801       -9     
  Partials        130      130              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@armiol armiol 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.

@alexander-yevsyukov fingers crossed, LGTM.

@alexander-yevsyukov alexander-yevsyukov merged commit 313a647 into master Jul 11, 2026
12 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the fix-launch-task-exec-time-config branch July 11, 2026 12:59
@github-project-automation github-project-automation Bot moved this from In Review to ✅ Done in v2.0 Jul 11, 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.

3 participants