From 7d8a153b21ec27d163dd01b9d41d51082d906b5b Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:24:13 +0100 Subject: [PATCH 01/10] Bump version -> `2.0.0-SNAPSHOT.079` Co-Authored-By: Claude Opus 5.5 --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index 93e51c0aedc..3bde32e4bd4 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -30,7 +30,7 @@ * This version is also used by integration test projects. * E.g. see `tests/consumer/build.gradle.kts`. */ -private val compilerVersion = "2.0.0-SNAPSHOT.077" +private val compilerVersion = "2.0.0-SNAPSHOT.079" extra.set("compilerVersion", compilerVersion) /** From f1ab2c8b97503a2d82686ecfa7fd8ccdfbcc4803 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:24:33 +0100 Subject: [PATCH 02/10] Add `disableProtobufVersionCheck` to the `compiler { }` DSL Setting `compiler { disableProtobufVersionCheck.set(true) }` makes every `LaunchSpineCompiler` task pass `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true` to the forked Compiler JVM. This is a shortcut for users hitting the Protobuf gencode/runtime version check, e.g. when their Compiler plugins are built with a different Protobuf version. The variable is added in `exec()` because Gradle does not unpack providers in `JavaExec` environment values, and the task may be configured before the `compiler { }` block runs. When the flag is `false`, the inherited environment is left intact, so a variable exported for the build still reaches the fork. The setting does not affect the Gradle daemon or the `protoc` plugins. Co-Authored-By: Claude Opus 5.5 --- .../tasks/disable-protobuf-version-check.md | 91 ++++++++++++++++ .../compiler/gradle/api/CompilerSettings.kt | 37 +++++++ gradle-plugin/README.md | 39 ++++++- .../tools/compiler/gradle/plugin/Extension.kt | 14 ++- .../gradle/plugin/LaunchSpineCompiler.kt | 49 +++++++++ .../compiler/gradle/plugin/ExtensionSpec.kt | 9 +- .../plugin/LaunchTaskEnvironmentSpec.kt | 101 ++++++++++++++++++ 7 files changed, 332 insertions(+), 8 deletions(-) create mode 100644 .agents/tasks/disable-protobuf-version-check.md create mode 100644 gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt diff --git a/.agents/tasks/disable-protobuf-version-check.md b/.agents/tasks/disable-protobuf-version-check.md new file mode 100644 index 00000000000..09980ce8466 --- /dev/null +++ b/.agents/tasks/disable-protobuf-version-check.md @@ -0,0 +1,91 @@ +--- +slug: disable-protobuf-version-check +branch: disable-protobuf-version-check +owner: claude +status: in-review +started: 2026-10-19 +--- + +## Goal + +Users can turn off the Protobuf runtime/gencode version check in the process +of the Compiler with a DSL call instead of exporting an environment variable: + +```kotlin +spine { + compiler { + disableProtobufVersionCheck.set(true) + } +} +``` + +When set to `true`, every `LaunchSpineCompiler` task passes +`TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true` to the forked Compiler JVM. + +## Context + +- `protobuf-java` 4.x validates the gencode version against the runtime in + `RuntimeVersion.validateProtobufGencodeVersion()` and skips the check only + when `System.getenv("TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK")` is `"true"`. + The Compiler fork is where a user classpath (plugins built with another + `protoc`) meets the Compiler's Protobuf runtime, so it is the process where + users hit the check. +- Today the only ways are exporting the variable for the Gradle daemon, or + `tasks.withType { environment(...) }`. The new property + is a convenience shortcut for the latter. +- Gradle 9.8.1 (this branch's wrapper; also checked 9.7.1) + `DefaultProcessForkOptions.getActualEnvironment()` converts values + with `String.valueOf()` — no `Provider` unpacking. `JavaExec.getEnvironment()` + is marked `@ToBeReplacedByLazyProperty`; once it is lazy, move the write to + configuration time. Launch tasks are realized + while the plugin is applied, before the user's `compiler { }` block runs, so + the flag must be read at execution time. +- `JavaExec.getEnvironment()` is a plain `@Internal` map (not a tracked + `Property`), so setting it in the `exec()` override does not trip the + "changing property value at execution time" deprecation addressed by + `fix-launch-task-exec-time-config`. +- `Extension` is the only implementation of `CompilerSettings` across Spine repos + (`core-jvm-compiler` only calls it), so adding an interface member is safe. +- Out of scope: the Gradle daemon and the `protoc` plugin processes. Their + environment cannot be changed from the build script; users still export the + variable for those. +- Not covered end-to-end: the functional tests export the variable for every + fixture build (`RunnerTuning.tuneRunner()`), so a TestKit test cannot tell + the cases apart. The `exec()` call is a one-liner; the helper is unit-tested. + +## Plan + +- [x] `CompilerSettings` (`gradle-api`): add + `public val disableProtobufVersionCheck: Property` with KDoc. +- [x] `Extension` (`gradle-plugin`): implement it with `convention(false)`. +- [x] `LaunchSpineCompiler`: + - [x] `@get:Internal internal abstract val disableProtobufVersionCheck: + Property` — internal because it does not affect the outputs. + - [x] Wire it to the extension in `applyDefaults()`. + - [x] In `exec()`, add the variable to `environment` only when the flag is + `true`; when `false`, leave the inherited environment untouched so a + variable exported for the daemon still reaches the fork. +- [x] Tests (`gradle-plugin/src/test`): + - [x] `ExtensionSpec` — default `false` (a "can be set" case would only + test Gradle's `Property`; dropped). + - [x] `LaunchTaskEnvironmentSpec` — flag `true` adds the variable; flag + `false` leaves a planted inherited value intact. +- [x] Docs: `gradle-plugin/README.md` configuration table + a short section on + when to use it and its scope. +- [x] Version bump `.077` → `.079` (`.078` is taken by + `origin/align-protobuf-runtime`), `./gradlew build`, dependency reports, + `dokkaGenerate`. +- [x] Commits: `` Bump version -> `2.0.0-SNAPSHOT.079` ``, the feature, and + `Update dependency reports`. + +## Log + +- 2026-10-19 — drafted in worktree `.claude/worktrees/disable-protobuf-version-check` + branched from `origin/master` @ `977762d8f9`. +- 2026-10-19 — implemented; `./gradlew build dokkaGenerate` green; reviews by + `kotlin-engineer` (APPROVE), `spine-code-review` and `review-docs` + (APPROVE WITH CHANGES) applied: planted-value test, `protoc` plugins wording, + `applyDefaults` KDoc exception note. +- 2026-10-19 — the worktree's pinned `.agents/shared` `version-bumped.sh` cannot + parse `extra.set(...)` in `version.gradle.kts` (exit 2); the floated copy in + the main checkout handles it. Fixed upstream; resolves on the next `config` pull. diff --git a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt index 90e87df18ea..14b89ba49aa 100644 --- a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt +++ b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt @@ -27,6 +27,7 @@ package io.spine.tools.compiler.gradle.api import org.gradle.api.file.DirectoryProperty +import org.gradle.api.provider.Property /** * Configures the code generation process performed by the Compiler. @@ -64,4 +65,40 @@ public interface CompilerSettings { * By default, points at the `$projectDir/generated/` directory. */ public val outputBaseDir: DirectoryProperty + + /** + * Tells whether the Protobuf version check is disabled in the Compiler process. + * + * The Protobuf runtime checks that the code generated by `protoc` is compatible + * with the runtime — in particular, that it is not newer than the runtime — and + * fails otherwise. Such a mismatch may occur when the plugins passed to the Compiler + * are built with a version of Protobuf different from the one used by the Compiler. + * + * When set to `true`, the `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` environment + * variable is set to `true` for the Compiler process, which turns the check off. + * This is a shortcut for setting the variable in the environment of + * the `LaunchSpineCompiler` tasks directly. + * + * When set to `false`, the environment of the Compiler process is left as is, + * so a variable set in the environment of the build still reaches the Compiler. + * + * The setting affects neither the Gradle daemon nor the `protoc` plugins. + * If the check fails there, set the variable in the environment of the build instead. + * + * Use this setting only as a temporary workaround until the Protobuf versions + * are aligned. + * + * The default value is `false`. + * + * Example (`build.gradle.kts`): + * + * ```kotlin + * spine { + * compiler { + * disableProtobufVersionCheck.set(true) + * } + * } + * ``` + */ + public val disableProtobufVersionCheck: Property } diff --git a/gradle-plugin/README.md b/gradle-plugin/README.md index 256627ea976..fe37f506cbe 100644 --- a/gradle-plugin/README.md +++ b/gradle-plugin/README.md @@ -51,11 +51,12 @@ The Compiler runs the plugins you specify via the `compiler { }` extension, nest Here is the complete list of configuration options: -| Name | Format | Description | Default value | -|-----------------|------------------|-------------------------------------------------------------------------------------------|----------------------------------------| -| `plugins` | Java class names | Class names of `io.spine.tools.compiler.plugin.Plugin` implementations the Compiler runs. | None | -| `subDirs` | Directory names | Subdirectories under the generated source set that the Compiler processes. | `java`, `kotlin`, `grpc`, `js`, `dart` | -| `outputBaseDir` | Directory | Base directory where the files generated by the Compiler are placed. | `$projectDir/generated/` | +| Name | Format | Description | Default value | +|-------------------------------|------------------|-------------------------------------------------------------------------------------------|----------------------------------------| +| `plugins` | Java class names | Class names of `io.spine.tools.compiler.plugin.Plugin` implementations the Compiler runs. | None | +| `subDirs` | Directory names | Subdirectories under the generated source set that the Compiler processes. | `java`, `kotlin`, `grpc`, `js`, `dart` | +| `outputBaseDir` | Directory | Base directory where the files generated by the Compiler are placed. | `$projectDir/generated/` | +| `disableProtobufVersionCheck` | Boolean | Whether to disable the [Protobuf version check](#protobuf-version-check) in the Compiler. | `false` | A complete configuration may look as follows: ```kotlin @@ -79,6 +80,34 @@ dependencies { } ``` +### Protobuf version check + +The Protobuf runtime checks that the code generated by `protoc` is compatible with the runtime — +in particular, that it is not newer than the runtime — and fails otherwise. The Compiler may hit +this check when a plugin passed to it is built with a version of Protobuf different from the one +used by the Compiler. + +As a temporary workaround, until the Protobuf versions are aligned, the check may be turned off +for the Compiler process: + +```kotlin +spine { + compiler { + disableProtobufVersionCheck.set(true) + } +} +``` + +This sets the `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` environment variable to `true` for +all the [`LaunchSpineCompiler`](#source-sets) tasks of the project. + +The setting affects neither the Gradle daemon nor the `protoc` plugins. +If the check fails there, set the variable in the environment of the build instead: + +```bash +TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true ./gradlew build +``` + ## Source sets For each source set in the project, the plugin generates a distinct task launching the Compiler. diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt index e9323cc3eba..155f8ffc347 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025, TeamDev. All rights reserved. + * Copyright 2026, TeamDev. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,9 +37,11 @@ import org.gradle.api.file.Directory import org.gradle.api.file.DirectoryProperty import org.gradle.api.plugins.ExtensionContainer import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.SourceSet import org.gradle.kotlin.dsl.listProperty +import org.gradle.kotlin.dsl.property /** * The `compiler { }` Gradle project extension. @@ -108,6 +110,16 @@ public class Extension(private val project: Project): CompilerSettings { ) } + /** + * Allows disabling the Protobuf version check in the Compiler process. + * + * Defaults to `false`. + * + * @see CompilerSettings.disableProtobufVersionCheck + */ + public override val disableProtobufVersionCheck: Property = + factory.property().convention(false) + /** * Obtains the source directories for the given source set. */ diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt index ea3b3640d5c..22dfdefea42 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt @@ -27,6 +27,7 @@ package io.spine.tools.compiler.gradle.plugin import com.google.protobuf.gradle.GenerateProtoTask +import io.spine.annotation.VisibleForTesting import io.spine.tools.code.SourceSetName import io.spine.tools.compiler.Constants.CLI_APP_CLASS import io.spine.tools.compiler.ast.toAbsoluteFile @@ -178,6 +179,17 @@ public abstract class LaunchSpineCompiler : JavaExec() { @get:Internal internal abstract val protoSourceDirs: ConfigurableFileCollection + /** + * Tells whether the Protobuf version check is disabled in the Compiler process. + * + * The property is [Internal] because disabling the check does not affect + * the generated code: the check either passes or fails the task. + * + * @see io.spine.tools.compiler.gradle.api.CompilerSettings.disableProtobufVersionCheck + */ + @get:Internal + internal abstract val disableProtobufVersionCheck: Property + @get:InputFiles @get:Classpath internal lateinit var userClasspathConfiguration: Configuration @@ -227,12 +239,36 @@ public abstract class LaunchSpineCompiler : JavaExec() { * The cleanup runs only when the task itself executes: a task that is * up-to-date, or restored from the build cache, leaves the previously * generated code intact. + * + * If requested via the `compiler { }` extension, disables the Protobuf version check + * in the Compiler process. */ override fun exec() { cleanTargetDirs() + disableProtobufVersionCheckIfRequested() super.exec() } + /** + * Sets the [PROTOBUF_VERSION_CHECK_ENV] environment variable to `true` for + * the Compiler process, if [disableProtobufVersionCheck] is `true`. + * + * Otherwise, leaves the environment intact, so that a variable set in + * the environment of the build still reaches the Compiler. + * + * The environment is amended when the task executes rather than when it is + * configured: the property may be set after the task is configured, and Gradle + * does not evaluate providers passed as environment values. Once Gradle turns + * the environment of `JavaExec` into a lazy property, the variable can be set + * at configuration time instead. + */ + @VisibleForTesting + internal fun disableProtobufVersionCheckIfRequested() { + if (disableProtobufVersionCheck.get()) { + environment(PROTOBUF_VERSION_CHECK_ENV, "true") + } + } + /** * Deletes the existing non-empty [target][targets] directories of this task. * @@ -269,6 +305,10 @@ public abstract class LaunchSpineCompiler : JavaExec() { * Touching the task state at execution time is deprecated: querying * `Task.dependsOn` fails in Gradle 10, changing a property in Gradle 11. * + * The environment of the Compiler process is the only exception: `exec()` amends it + * via `disableProtobufVersionCheckIfRequested()`. The environment is a plain map + * rather than a tracked property, so the amendment is not subject to the deprecation. + * * @param sourceSet The source set for which the task is created. */ internal fun LaunchSpineCompiler.applyDefaults(sourceSet: SourceSet) { @@ -276,6 +316,7 @@ internal fun LaunchSpineCompiler.applyDefaults(sourceSet: SourceSet) { val project = project val ext = project.compilerSettings plugins = ext.plugins + disableProtobufVersionCheck.set(ext.disableProtobufVersionCheck) compilerConfiguration = project.compilerRawArtifact userClasspathConfiguration = project.userClasspath classpath(compilerConfiguration) @@ -412,6 +453,14 @@ internal fun LaunchSpineCompiler.hasRequestFile(sourceSet: SourceSet): Boolean { return file.exists() } +/** + * The name of the environment variable which turns off the check of the code + * generated by `protoc` against the version of the Protobuf runtime. + * + * The Protobuf runtime skips the check if the variable is set to `true`. + */ +private const val PROTOBUF_VERSION_CHECK_ENV = "TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK" + private val Project.compilerRawArtifact: Configuration get() = configurations.getByName(COMPILER_RAW_ARTIFACT) diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt index 6e815d7a484..ba241a3dee1 100644 --- a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025, TeamDev. All rights reserved. + * Copyright 2026, TeamDev. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class ExtensionSpec { private lateinit var project: Project private lateinit var extension: Extension - + @BeforeEach fun prepareProject(@TempDir projectDir: File) { project = ProjectBuilder.builder() @@ -87,6 +87,11 @@ class ExtensionSpec { targetDirs[0].toPath() shouldBe mainDir / expected[0] targetDirs[1].toPath() shouldBe mainDir / expected[1] } + + @Test + fun `keep the Protobuf version check enabled by default`() { + extension.disableProtobufVersionCheck.get() shouldBe false + } } private fun Directory.toPath() = asFile.toPath() diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt new file mode 100644 index 00000000000..263c600bd5a --- /dev/null +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt @@ -0,0 +1,101 @@ +/* + * Copyright 2026, TeamDev. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.spine.tools.compiler.gradle.plugin + +import com.google.protobuf.gradle.ProtobufPlugin +import io.kotest.matchers.shouldBe +import io.kotest.matchers.types.shouldBeInstanceOf +import io.spine.tools.code.SourceSetName +import io.spine.tools.compiler.gradle.api.CompilerTaskName +import java.io.File +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.testfixtures.ProjectBuilder +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir + +/** + * Verifies that [LaunchSpineCompiler] passes the variable disabling the Protobuf + * version check to the process of the Compiler as configured via + * [Extension.disableProtobufVersionCheck]. + */ +@DisplayName("`LaunchSpineCompiler` should") +internal class LaunchTaskEnvironmentSpec { + + private lateinit var project: Project + private lateinit var task: LaunchSpineCompiler + + @BeforeEach + fun prepareProject(@TempDir projectDir: File) { + project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + with(project) { + apply(plugin = "java") + apply() + apply() + } + val taskName = CompilerTaskName(SourceSetName.main).value() + // Obtaining the task configures it before the extension is changed by a test, + // as in a real build, where the task is configured before the `compiler { }` block runs. + task = project.tasks.getByName(taskName).shouldBeInstanceOf() + } + + @Test + fun `leave the inherited environment intact by default`() { + // A value other than `true` tells an untouched variable from an overwritten one, + // regardless of the environment of the machine running the test. + val inherited = "inherited-from-build" + task.environment(ENV_VARIABLE, inherited) + + task.disableProtobufVersionCheckIfRequested() + + task.environment[ENV_VARIABLE] shouldBe inherited + } + + @Test + fun `disable the Protobuf version check when requested via the extension`() { + project.compilerSettings.disableProtobufVersionCheck.set(true) + + task.disableProtobufVersionCheckIfRequested() + + task.environment[ENV_VARIABLE] shouldBe "true" + } + + private companion object { + + /** + * The name of the variable checked by the Protobuf runtime. + * + * The name is repeated here rather than referenced to lock the exact value + * expected by the Protobuf runtime. + */ + const val ENV_VARIABLE = "TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK" + } +} From f36d66ed042a0a164990c88a3f55252394b056fe Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:24:52 +0100 Subject: [PATCH 03/10] Update dependency reports Co-Authored-By: Claude Opus 5.5 --- docs/dependencies/dependencies.md | 44 +++++++++++++++---------------- docs/dependencies/pom.xml | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/dependencies/dependencies.md b/docs/dependencies/dependencies.md index ecc72107d7a..8583e897231 100644 --- a/docs/dependencies/dependencies.md +++ b/docs/dependencies/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:compiler-api:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-api:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -1864,14 +1864,14 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-api-tests:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-api-tests:2.0.0-SNAPSHOT.079` ## Runtime ## Compile, tests, and tooling @@ -2582,14 +2582,14 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:42 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-backend:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-backend:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -4457,14 +4457,14 @@ This report was generated on **Fri Oct 16 23:08:42 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-cli:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-cli:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -6540,14 +6540,14 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-gradle-api:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-gradle-api:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -8301,14 +8301,14 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-gradle-plugin:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-gradle-plugin:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -10102,14 +10102,14 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-jvm:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-jvm:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -12043,14 +12043,14 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-params:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-params:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -13906,14 +13906,14 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-protoc-plugin:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-protoc-plugin:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -14820,14 +14820,14 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:42 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-test-env:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-test-env:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -16671,14 +16671,14 @@ This report was generated on **Fri Oct 16 23:08:42 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-testlib:2.0.0-SNAPSHOT.077` +# Dependencies of `io.spine.tools:compiler-testlib:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -18647,6 +18647,6 @@ This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Oct 16 23:08:43 WEST 2026** using +This report was generated on **Mon Oct 19 20:06:03 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/docs/dependencies/pom.xml b/docs/dependencies/pom.xml index 50266b6debf..8352de250e8 100644 --- a/docs/dependencies/pom.xml +++ b/docs/dependencies/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.tools compiler -2.0.0-SNAPSHOT.077 +2.0.0-SNAPSHOT.079 2015 From 9f497e39c96164fbb25805ac60f7d881c8f1c994 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:29:34 +0100 Subject: [PATCH 04/10] Apply the CodeMatters copyright notice to the changed files Co-Authored-By: Claude Opus 5.5 --- .../compiler/gradle/api/CompilerSettings.kt | 26 +++++-------------- .../tools/compiler/gradle/plugin/Extension.kt | 26 +++++-------------- .../gradle/plugin/LaunchSpineCompiler.kt | 26 +++++-------------- .../compiler/gradle/plugin/ExtensionSpec.kt | 26 +++++-------------- .../plugin/LaunchTaskEnvironmentSpec.kt | 26 +++++-------------- 5 files changed, 35 insertions(+), 95 deletions(-) diff --git a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt index 14b89ba49aa..8d10aaa4df7 100644 --- a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt +++ b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt @@ -1,27 +1,15 @@ /* - * Copyright 2026, TeamDev. All rights reserved. + * Copyright 2026 CodeMatters, Lda. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. */ package io.spine.tools.compiler.gradle.api diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt index 155f8ffc347..a7ad766e8e8 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt @@ -1,27 +1,15 @@ /* - * Copyright 2026, TeamDev. All rights reserved. + * Copyright 2026 CodeMatters, Lda. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. */ package io.spine.tools.compiler.gradle.plugin diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt index 22dfdefea42..591a210d635 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt @@ -1,27 +1,15 @@ /* - * Copyright 2026, TeamDev. All rights reserved. + * Copyright 2026 CodeMatters, Lda. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. */ package io.spine.tools.compiler.gradle.plugin diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt index ba241a3dee1..24947d6d400 100644 --- a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt @@ -1,27 +1,15 @@ /* - * Copyright 2026, TeamDev. All rights reserved. + * Copyright 2026 CodeMatters, Lda. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. */ package io.spine.tools.compiler.gradle.plugin diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt index 263c600bd5a..66234f5074a 100644 --- a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt @@ -1,27 +1,15 @@ /* - * Copyright 2026, TeamDev. All rights reserved. + * Copyright 2026 CodeMatters, Lda. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. */ package io.spine.tools.compiler.gradle.plugin From a6cff89b03953500b6f68b59d9d72d2b857caeba Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:40:01 +0100 Subject: [PATCH 05/10] Describe the version check in light of the aligned Protobuf runtime Since `align-protobuf-runtime` (#90), the Compiler runs on the highest Protobuf runtime requested by the CLI and by its plugins, so a newer plugin runtime no longer fails the check. The docs now name the remaining case: a build forcing a runtime older than the one the plugins were built with. Co-Authored-By: Claude Opus 5.5 --- .agents/tasks/disable-protobuf-version-check.md | 8 ++++++-- .../spine/tools/compiler/gradle/api/CompilerSettings.kt | 6 ++++-- gradle-plugin/README.md | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.agents/tasks/disable-protobuf-version-check.md b/.agents/tasks/disable-protobuf-version-check.md index 09980ce8466..4a56b8c033f 100644 --- a/.agents/tasks/disable-protobuf-version-check.md +++ b/.agents/tasks/disable-protobuf-version-check.md @@ -49,9 +49,13 @@ When set to `true`, every `LaunchSpineCompiler` task passes - Out of scope: the Gradle daemon and the `protoc` plugin processes. Their environment cannot be changed from the build script; users still export the variable for those. +- After #90 (`align-protobuf-runtime`), the fork runs on the highest Protobuf runtime + requested by the CLI and by `spineCompiler`, so a newer plugin runtime no longer + fails. The setting remains for builds that force an older runtime (e.g. via `force`). - Not covered end-to-end: the functional tests export the variable for every - fixture build (`RunnerTuning.tuneRunner()`), so a TestKit test cannot tell - the cases apart. The `exec()` call is a one-liner; the helper is unit-tested. + fixture build (`RunnerTuning.tuneRunner()`). The `protobuf-runtime-test` fixture + from #90 removes it in the fork, so a follow-up can force an older runtime there + and show the flag fixing the failure. The helper is unit-tested here. ## Plan diff --git a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt index 8d10aaa4df7..65580848ee7 100644 --- a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt +++ b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt @@ -59,8 +59,10 @@ public interface CompilerSettings { * * The Protobuf runtime checks that the code generated by `protoc` is compatible * with the runtime — in particular, that it is not newer than the runtime — and - * fails otherwise. Such a mismatch may occur when the plugins passed to the Compiler - * are built with a version of Protobuf different from the one used by the Compiler. + * fails otherwise. The Compiler runs on the highest Protobuf runtime requested by + * the Compiler itself and by its plugins, which avoids such a failure in most cases. + * The check may still fail, for example, when the build forces a Protobuf runtime + * older than the one the plugins were built with. * * When set to `true`, the `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` environment * variable is set to `true` for the Compiler process, which turns the check off. diff --git a/gradle-plugin/README.md b/gradle-plugin/README.md index fe37f506cbe..826c2e6559b 100644 --- a/gradle-plugin/README.md +++ b/gradle-plugin/README.md @@ -83,9 +83,10 @@ dependencies { ### Protobuf version check The Protobuf runtime checks that the code generated by `protoc` is compatible with the runtime — -in particular, that it is not newer than the runtime — and fails otherwise. The Compiler may hit -this check when a plugin passed to it is built with a version of Protobuf different from the one -used by the Compiler. +in particular, that it is not newer than the runtime — and fails otherwise. The Compiler runs on +the highest Protobuf runtime requested by the Compiler itself and by its plugins, which avoids +such a failure in most cases. The check may still fail, for example, when the build forces +a Protobuf runtime older than the one the plugins were built with. As a temporary workaround, until the Protobuf versions are aligned, the check may be turned off for the Compiler process: From 11b0e6eccd8e8969bc71123c8baf695249f6d277 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:40:35 +0100 Subject: [PATCH 06/10] Update dependency reports Co-Authored-By: Claude Opus 5.5 --- docs/dependencies/dependencies.md | 44 +++++++++++++++---------------- docs/dependencies/pom.xml | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/dependencies/dependencies.md b/docs/dependencies/dependencies.md index f4125572ea6..d1748189ae3 100644 --- a/docs/dependencies/dependencies.md +++ b/docs/dependencies/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:compiler-api:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-api:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -1864,14 +1864,14 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:54 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-api-tests:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-api-tests:2.0.0-SNAPSHOT.079` ## Runtime ## Compile, tests, and tooling @@ -2582,14 +2582,14 @@ This report was generated on **Mon Oct 19 19:23:54 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:30 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:18 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-backend:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-backend:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -4457,14 +4457,14 @@ This report was generated on **Mon Oct 19 19:23:30 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:56 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-cli:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-cli:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -6540,14 +6540,14 @@ This report was generated on **Mon Oct 19 19:23:56 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:56 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-gradle-api:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-gradle-api:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -8301,14 +8301,14 @@ This report was generated on **Mon Oct 19 19:23:56 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:55 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-gradle-plugin:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-gradle-plugin:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -10102,14 +10102,14 @@ This report was generated on **Mon Oct 19 19:23:55 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:56 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-jvm:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-jvm:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -12043,14 +12043,14 @@ This report was generated on **Mon Oct 19 19:23:56 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:32 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-params:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-params:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -13906,14 +13906,14 @@ This report was generated on **Mon Oct 19 19:23:32 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:55 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-protoc-plugin:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-protoc-plugin:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -14820,14 +14820,14 @@ This report was generated on **Mon Oct 19 19:23:55 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:32 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:18 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-test-env:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-test-env:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -16671,14 +16671,14 @@ This report was generated on **Mon Oct 19 19:23:32 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:31 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:compiler-testlib:2.0.0-SNAPSHOT.078` +# Dependencies of `io.spine.tools:compiler-testlib:2.0.0-SNAPSHOT.079` ## Runtime 1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3. @@ -18647,6 +18647,6 @@ This report was generated on **Mon Oct 19 19:23:31 WEST 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Oct 19 19:23:56 WEST 2026** using +This report was generated on **Mon Oct 19 20:40:19 WEST 2026** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/docs/dependencies/pom.xml b/docs/dependencies/pom.xml index 6886a09c4cc..ded1c2122a5 100644 --- a/docs/dependencies/pom.xml +++ b/docs/dependencies/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.tools compiler -2.0.0-SNAPSHOT.078 +2.0.0-SNAPSHOT.079 2015 From 4b463c7ede05190b90455bea5281ecad319a7f3b Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:48:37 +0100 Subject: [PATCH 07/10] Remove the version check variable when the setting is `false` `disableProtobufVersionCheck.set(false)` used to leave the environment of the Compiler process as is, so a variable exported for the build still turned the check off. Now `false` removes the variable, enforcing the check. The property is no longer `false` by default but not set: a default that removed the variable would break builds relying on the exported variable, including the functional tests of this repo. When not set, the Compiler process inherits the variable from the build, as before. Co-Authored-By: Claude Opus 5.5 --- .../compiler/gradle/api/CompilerSettings.kt | 19 +++++++----- gradle-plugin/README.md | 6 +++- .../tools/compiler/gradle/plugin/Extension.kt | 5 +-- .../gradle/plugin/LaunchSpineCompiler.kt | 31 ++++++++++++------- .../compiler/gradle/plugin/ExtensionSpec.kt | 4 +-- .../plugin/LaunchTaskEnvironmentSpec.kt | 22 ++++++++++--- 6 files changed, 57 insertions(+), 30 deletions(-) diff --git a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt index 65580848ee7..28c5aa6217f 100644 --- a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt +++ b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt @@ -55,7 +55,7 @@ public interface CompilerSettings { public val outputBaseDir: DirectoryProperty /** - * Tells whether the Protobuf version check is disabled in the Compiler process. + * Tells whether to disable the Protobuf version check in the Compiler process. * * The Protobuf runtime checks that the code generated by `protoc` is compatible * with the runtime — in particular, that it is not newer than the runtime — and @@ -64,22 +64,25 @@ public interface CompilerSettings { * The check may still fail, for example, when the build forces a Protobuf runtime * older than the one the plugins were built with. * - * When set to `true`, the `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` environment - * variable is set to `true` for the Compiler process, which turns the check off. + * The check is turned off by the `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` + * environment variable set to `true`. This property controls the variable in + * the environment of the Compiler process: + * + * - `true` sets the variable to `true`, turning the check off; + * - `false` removes the variable, so the check is performed even if the variable + * is set in the environment of the build; + * - when the property is not set, which is the default, the Compiler process + * inherits the variable from the environment of the build, if any. + * * This is a shortcut for setting the variable in the environment of * the `LaunchSpineCompiler` tasks directly. * - * When set to `false`, the environment of the Compiler process is left as is, - * so a variable set in the environment of the build still reaches the Compiler. - * * The setting affects neither the Gradle daemon nor the `protoc` plugins. * If the check fails there, set the variable in the environment of the build instead. * * Use this setting only as a temporary workaround until the Protobuf versions * are aligned. * - * The default value is `false`. - * * Example (`build.gradle.kts`): * * ```kotlin diff --git a/gradle-plugin/README.md b/gradle-plugin/README.md index 826c2e6559b..c35de8e61b8 100644 --- a/gradle-plugin/README.md +++ b/gradle-plugin/README.md @@ -56,7 +56,7 @@ Here is the complete list of configuration options: | `plugins` | Java class names | Class names of `io.spine.tools.compiler.plugin.Plugin` implementations the Compiler runs. | None | | `subDirs` | Directory names | Subdirectories under the generated source set that the Compiler processes. | `java`, `kotlin`, `grpc`, `js`, `dart` | | `outputBaseDir` | Directory | Base directory where the files generated by the Compiler are placed. | `$projectDir/generated/` | -| `disableProtobufVersionCheck` | Boolean | Whether to disable the [Protobuf version check](#protobuf-version-check) in the Compiler. | `false` | +| `disableProtobufVersionCheck` | Boolean | Whether to disable the [Protobuf version check](#protobuf-version-check) in the Compiler. | Not set | A complete configuration may look as follows: ```kotlin @@ -102,6 +102,10 @@ spine { This sets the `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` environment variable to `true` for all the [`LaunchSpineCompiler`](#source-sets) tasks of the project. +Setting the property to `false` removes the variable from the environment of these tasks, +so the check is performed even if the variable is set for the build. When the property is +not set, which is the default, the tasks inherit the variable from the environment of the build. + The setting affects neither the Gradle daemon nor the `protoc` plugins. If the check fails there, set the variable in the environment of the build instead: diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt index a7ad766e8e8..966ab69d7e0 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt @@ -101,12 +101,13 @@ public class Extension(private val project: Project): CompilerSettings { /** * Allows disabling the Protobuf version check in the Compiler process. * - * Defaults to `false`. + * Not set by default, so the Compiler process inherits the setting from + * the environment of the build. * * @see CompilerSettings.disableProtobufVersionCheck */ public override val disableProtobufVersionCheck: Property = - factory.property().convention(false) + factory.property() /** * Obtains the source directories for the given source set. diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt index 591a210d635..016b3daf469 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt @@ -168,7 +168,10 @@ public abstract class LaunchSpineCompiler : JavaExec() { internal abstract val protoSourceDirs: ConfigurableFileCollection /** - * Tells whether the Protobuf version check is disabled in the Compiler process. + * Tells whether to disable the Protobuf version check in the Compiler process. + * + * When not set, the Compiler process inherits the setting from the environment + * of the build. * * The property is [Internal] because disabling the check does not affect * the generated code: the check either passes or fails the task. @@ -228,21 +231,23 @@ public abstract class LaunchSpineCompiler : JavaExec() { * up-to-date, or restored from the build cache, leaves the previously * generated code intact. * - * If requested via the `compiler { }` extension, disables the Protobuf version check - * in the Compiler process. + * Applies the Protobuf version check setting of the `compiler { }` extension + * to the environment of the Compiler process. */ override fun exec() { cleanTargetDirs() - disableProtobufVersionCheckIfRequested() + applyProtobufVersionCheckSetting() super.exec() } /** - * Sets the [PROTOBUF_VERSION_CHECK_ENV] environment variable to `true` for - * the Compiler process, if [disableProtobufVersionCheck] is `true`. + * Applies [disableProtobufVersionCheck] to the [PROTOBUF_VERSION_CHECK_ENV] + * environment variable of the Compiler process. * - * Otherwise, leaves the environment intact, so that a variable set in - * the environment of the build still reaches the Compiler. + * Sets the variable to `true` if the property is `true`, and removes the variable + * if the property is `false`. When the property is not set, leaves the environment + * intact, so that the variable set in the environment of the build still reaches + * the Compiler. * * The environment is amended when the task executes rather than when it is * configured: the property may be set after the task is configured, and Gradle @@ -251,9 +256,11 @@ public abstract class LaunchSpineCompiler : JavaExec() { * at configuration time instead. */ @VisibleForTesting - internal fun disableProtobufVersionCheckIfRequested() { - if (disableProtobufVersionCheck.get()) { - environment(PROTOBUF_VERSION_CHECK_ENV, "true") + internal fun applyProtobufVersionCheckSetting() { + when (disableProtobufVersionCheck.orNull) { + true -> environment(PROTOBUF_VERSION_CHECK_ENV, "true") + false -> environment.remove(PROTOBUF_VERSION_CHECK_ENV) + null -> {} // Inherit the variable from the environment of the build. } } @@ -294,7 +301,7 @@ public abstract class LaunchSpineCompiler : JavaExec() { * `Task.dependsOn` fails in Gradle 10, changing a property in Gradle 11. * * The environment of the Compiler process is the only exception: `exec()` amends it - * via `disableProtobufVersionCheckIfRequested()`. The environment is a plain map + * via `applyProtobufVersionCheckSetting()`. The environment is a plain map * rather than a tracked property, so the amendment is not subject to the deprecation. * * @param sourceSet The source set for which the task is created. diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt index 24947d6d400..f8a5b56d208 100644 --- a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/ExtensionSpec.kt @@ -77,8 +77,8 @@ class ExtensionSpec { } @Test - fun `keep the Protobuf version check enabled by default`() { - extension.disableProtobufVersionCheck.get() shouldBe false + fun `leave the Protobuf version check to the build environment by default`() { + extension.disableProtobufVersionCheck.isPresent shouldBe false } } diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt index 66234f5074a..0aed01b9dc9 100644 --- a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt @@ -15,6 +15,7 @@ package io.spine.tools.compiler.gradle.plugin import com.google.protobuf.gradle.ProtobufPlugin +import io.kotest.matchers.maps.shouldNotContainKey import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeInstanceOf import io.spine.tools.code.SourceSetName @@ -29,8 +30,8 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir /** - * Verifies that [LaunchSpineCompiler] passes the variable disabling the Protobuf - * version check to the process of the Compiler as configured via + * Verifies that [LaunchSpineCompiler] controls the variable disabling the Protobuf + * version check in the environment of the Compiler process as configured via * [Extension.disableProtobufVersionCheck]. */ @DisplayName("`LaunchSpineCompiler` should") @@ -62,20 +63,31 @@ internal class LaunchTaskEnvironmentSpec { val inherited = "inherited-from-build" task.environment(ENV_VARIABLE, inherited) - task.disableProtobufVersionCheckIfRequested() + task.applyProtobufVersionCheckSetting() task.environment[ENV_VARIABLE] shouldBe inherited } @Test - fun `disable the Protobuf version check when requested via the extension`() { + fun `disable the Protobuf version check when the extension says 'true'`() { project.compilerSettings.disableProtobufVersionCheck.set(true) - task.disableProtobufVersionCheckIfRequested() + task.applyProtobufVersionCheckSetting() task.environment[ENV_VARIABLE] shouldBe "true" } + @Test + fun `keep the Protobuf version check when the extension says 'false'`() { + // As if the variable were set in the environment of the build. + task.environment(ENV_VARIABLE, "true") + project.compilerSettings.disableProtobufVersionCheck.set(false) + + task.applyProtobufVersionCheckSetting() + + task.environment shouldNotContainKey ENV_VARIABLE + } + private companion object { /** From f6ba8d6e6b11ec1730674e320df9b34974a7b628 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 20:48:44 +0100 Subject: [PATCH 08/10] Test `disableProtobufVersionCheck` end to end `DisableProtobufVersionCheckSpec` reuses the `protobuf-runtime-test` fixture, which turns the check back on in the Compiler JVM. The plugin of the fixture is built with a Protobuf release newer than the CLI's runtime, and the runtime of the CLI configuration is forced to stay at the CLI's version, so the check fails for real: - `false`, with the variable set as if exported for the build, fails with `ProtobufRuntimeVersionException`; - `true` lets the Compiler run. The Protobuf versions and `isNewer()` of `ProtobufRuntimeSpec` become `internal` for the reuse. Co-Authored-By: Claude Opus 5.5 --- .../tasks/disable-protobuf-version-check.md | 37 +++-- .../plugin/DisableProtobufVersionCheckSpec.kt | 141 ++++++++++++++++++ .../gradle/plugin/ProtobufRuntimeSpec.kt | 6 +- 3 files changed, 167 insertions(+), 17 deletions(-) create mode 100644 gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt diff --git a/.agents/tasks/disable-protobuf-version-check.md b/.agents/tasks/disable-protobuf-version-check.md index 4a56b8c033f..0e191926976 100644 --- a/.agents/tasks/disable-protobuf-version-check.md +++ b/.agents/tasks/disable-protobuf-version-check.md @@ -19,8 +19,12 @@ spine { } ``` -When set to `true`, every `LaunchSpineCompiler` task passes -`TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true` to the forked Compiler JVM. +The property controls `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` in the environment +of every `LaunchSpineCompiler` fork: `true` sets it to `true` (check off), `false` +removes it (check on, even if the build exports it), not set (default) inherits it +from the build. A default that cleared the variable would silently break builds +relying on the exported variable, including this repo's functional tests +(`RunnerTuning.tuneRunner()`), hence three states rather than `false` by default. ## Context @@ -52,28 +56,28 @@ When set to `true`, every `LaunchSpineCompiler` task passes - After #90 (`align-protobuf-runtime`), the fork runs on the highest Protobuf runtime requested by the CLI and by `spineCompiler`, so a newer plugin runtime no longer fails. The setting remains for builds that force an older runtime (e.g. via `force`). -- Not covered end-to-end: the functional tests export the variable for every - fixture build (`RunnerTuning.tuneRunner()`). The `protobuf-runtime-test` fixture - from #90 removes it in the fork, so a follow-up can force an older runtime there - and show the flag fixing the failure. The helper is unit-tested here. +- End-to-end: the `protobuf-runtime-test` fixture from #90 removes the variable in + the fork. `DisableProtobufVersionCheckSpec` reuses it, forcing the CLI runtime + below the plugin gencode (`4.37.0-RC1`) so the check really fails. ## Plan - [x] `CompilerSettings` (`gradle-api`): add `public val disableProtobufVersionCheck: Property` with KDoc. -- [x] `Extension` (`gradle-plugin`): implement it with `convention(false)`. +- [x] `Extension` (`gradle-plugin`): implement it, not set by default. - [x] `LaunchSpineCompiler`: - [x] `@get:Internal internal abstract val disableProtobufVersionCheck: Property` — internal because it does not affect the outputs. - [x] Wire it to the extension in `applyDefaults()`. - - [x] In `exec()`, add the variable to `environment` only when the flag is - `true`; when `false`, leave the inherited environment untouched so a - variable exported for the daemon still reaches the fork. + - [x] In `exec()`, `applyProtobufVersionCheckSetting()`: `true` sets the + variable, `false` removes it, not set leaves the environment intact. - [x] Tests (`gradle-plugin/src/test`): - - [x] `ExtensionSpec` — default `false` (a "can be set" case would only - test Gradle's `Property`; dropped). - - [x] `LaunchTaskEnvironmentSpec` — flag `true` adds the variable; flag - `false` leaves a planted inherited value intact. + - [x] `ExtensionSpec` — not set by default. + - [x] `LaunchTaskEnvironmentSpec` — not set keeps a planted inherited value; + `true` sets the variable; `false` removes a planted `true`. +- [x] Functional test `DisableProtobufVersionCheckSpec` — `false` keeps the check + even when the build sets the variable (fails with + `ProtobufRuntimeVersionException`); `true` lets the Compiler run. - [x] Docs: `gradle-plugin/README.md` configuration table + a short section on when to use it and its scope. - [x] Version bump `.077` → `.079` (`.078` is taken by @@ -93,3 +97,8 @@ When set to `true`, every `LaunchSpineCompiler` task passes - 2026-10-19 — the worktree's pinned `.agents/shared` `version-bumped.sh` cannot parse `extra.set(...)` in `version.gradle.kts` (exit 2); the floated copy in the main checkout handles it. Fixed upstream; resolves on the next `config` pull. +- 2026-10-19 — PR #95 opened; merged `origin/master` after #90 landed (conflicts only + in `version.gradle.kts` and reports; kept `.079`); CodeMatters headers applied. +- 2026-10-19 — per review by the user, `false` now removes the variable; the default + became "not set" to keep the exported-variable workaround working. Added the + end-to-end spec. diff --git a/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt b/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt new file mode 100644 index 00000000000..d9c3e56ad50 --- /dev/null +++ b/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt @@ -0,0 +1,141 @@ +/* + * Copyright 2026 CodeMatters, Lda. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +package io.spine.tools.compiler.gradle.plugin + +import io.kotest.assertions.withClue +import io.kotest.matchers.shouldBe +import io.kotest.matchers.string.shouldContain +import io.spine.testing.SlowTest +import io.spine.tools.code.SourceSetName +import io.spine.tools.compiler.gradle.api.CompilerTaskName +import io.spine.tools.compiler.gradle.api.Names.COMPILER_RAW_ARTIFACT +import io.spine.tools.compiler.gradle.api.Names.GRADLE_PLUGIN_ID +import io.spine.tools.gradle.task.TaskName +import io.spine.tools.gradle.testing.GradleProject +import io.spine.tools.gradle.testing.get +import java.io.File +import org.gradle.api.logging.LogLevel +import org.gradle.testkit.runner.TaskOutcome.FAILED +import org.gradle.testkit.runner.TaskOutcome.SUCCESS +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir + +/** + * Verifies that `compiler { disableProtobufVersionCheck }` controls the Protobuf + * gencode/runtime version check in the JVM forked by [LaunchSpineCompiler]. + * + * The tests use the `protobuf-runtime-test` fixture of [ProtobufRuntimeSpec], which turns + * the check back on in the forked JVM. The plugin of the fixture is built with a Protobuf + * release newer than the runtime of the CLI. Each test forces the runtime of the CLI + * configuration, which comes first on the classpath of the forked JVM, to stay at the CLI's + * own version. So the gencode of the plugin finds a runtime older than itself, as in a build + * that forces an older Protobuf runtime. + */ +@SlowTest +@DisplayName("`disableProtobufVersionCheck` should") +internal class DisableProtobufVersionCheckSpec { + + private val launchSpineCompiler: TaskName = CompilerTaskName(SourceSetName.main) + + private lateinit var projectDir: File + + @BeforeEach + fun prepareDir(@TempDir projectDir: File) { + this.projectDir = projectDir + withClue("Pick a Protobuf release newer than `$CLI_PROTOBUF` for the test.") { + isNewer(NEWER_PROTOBUF, than = CLI_PROTOBUF) shouldBe true + } + } + + @Test + fun `keep the check when set to 'false', even if the build disables it`() { + val project = createProject( + """ + // Put the variable back, as if it were set in the environment of the build. + tasks.withType().configureEach { + environment("$VERSION_CHECK_VARIABLE", "true") + } + + spine { + compiler { + disableProtobufVersionCheck.set(false) + } + } + """ + ) + + val result = project.executeAndFail(launchSpineCompiler) + + result[launchSpineCompiler] shouldBe FAILED + result.output shouldContain "ProtobufRuntimeVersionException" + } + + @Test + fun `turn the check off when set to 'true'`() { + val project = createProject( + """ + spine { + compiler { + disableProtobufVersionCheck.set(true) + } + } + """ + ) + + val result = project.executeTask(launchSpineCompiler) + + result[launchSpineCompiler] shouldBe SUCCESS + } + + /** + * Creates the fixture project with the plugin built on [NEWER_PROTOBUF]. + * + * Appends to the build script of the project the code that forces the runtime of + * the CLI configuration to [CLI_PROTOBUF], followed by the given [caseSetup]. + * A `force` wins over the constraints the Compiler Gradle plugin derives from + * the user classpath, so the newer runtime of the plugin stays behind the CLI's one + * on the classpath of the forked JVM. + * + * @param caseSetup The build script code setting up the test case. + */ + private fun createProject(caseSetup: String): GradleProject { + val project = GradleProject.setupAt(projectDir) + .fromResources("protobuf-runtime-test") + .withSharedTestKitDirectory() + .replace("@COMPILER_PLUGIN_ID@", GRADLE_PLUGIN_ID) + .replace("@COMPILER_VERSION@", Plugin.version) + .replace("@PLUGIN_PROTOBUF@", NEWER_PROTOBUF) + .withLoggingLevel(LogLevel.INFO) + .copyBuildSrc() + .create() + project.tuneRunner() + val forceCliRuntime = """ + configurations.named("$COMPILER_RAW_ARTIFACT") { + resolutionStrategy.force("com.google.protobuf:protobuf-java:$CLI_PROTOBUF") + } + """ + projectDir.resolve("build.gradle.kts").appendText( + "\n" + forceCliRuntime.trimIndent() + "\n\n" + caseSetup.trimIndent() + "\n" + ) + return project + } +} + +/** + * The name of the variable checked by the Protobuf runtime. + */ +private const val VERSION_CHECK_VARIABLE = "TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK" diff --git a/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/ProtobufRuntimeSpec.kt b/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/ProtobufRuntimeSpec.kt index 4c23f1c709b..463989b042a 100644 --- a/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/ProtobufRuntimeSpec.kt +++ b/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/ProtobufRuntimeSpec.kt @@ -123,7 +123,7 @@ internal class ProtobufRuntimeSpec { * the build after the build moves to the latest stable release. Replace it once * the build reaches that minor version. */ -private const val NEWER_PROTOBUF = "4.37.0-RC1" +internal const val NEWER_PROTOBUF = "4.37.0-RC1" /** * A Protobuf release older than the one used by this build. @@ -136,7 +136,7 @@ private const val OLDER_PROTOBUF = "4.33.0" * It equals the version the CLI declares: both come from `Protobuf.libs`, which * the CLI declares in its POM, and the build forces in every configuration. */ -private val CLI_PROTOBUF = +internal val CLI_PROTOBUF = "${RuntimeVersion.MAJOR}.${RuntimeVersion.MINOR}.${RuntimeVersion.PATCH}" /** @@ -148,7 +148,7 @@ private val PROTOBUF_JAVA_JAR = Regex("""protobuf-java-\d.*\.jar""") * Tells whether the [version] is newer than the [than] version, comparing only * the major, minor, and patch numbers. A qualifier such as `-RC1` is ignored. */ -private fun isNewer(version: String, than: String): Boolean { +internal fun isNewer(version: String, than: String): Boolean { fun numbers(v: String) = v.substringBefore('-').split('.').map(String::toInt) val (mine, theirs) = numbers(version).zip(numbers(than)) .firstOrNull { (a, b) -> a != b } From 5cbff34aec11cb8cf3ff933154b153717f559d9f Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 21:23:29 +0100 Subject: [PATCH 09/10] Read the version check setting when the launch task is configured `LaunchSpineCompiler` no longer keeps a copy of `disableProtobufVersionCheck` and no longer amends its environment in `exec()`. `applyDefaults()` applies the extension's value instead, keeping the whole task state set at configuration time. The launch tasks are realized in the `afterEvaluate` hooks, after the build script body, so the `compiler { }` block has run. The extension property is `finalizeValueOnRead()`, so a change after the tasks read it fails instead of being silently ignored. A user's own `environment(...)` call on the task still wins, as it runs later. The `when` over the setting uses `else` for the unset case, which avoids an unreachable exhaustiveness branch in the bytecode (reported as partial coverage). Co-Authored-By: Claude Opus 5.5 --- .../tasks/disable-protobuf-version-check.md | 37 +++++----- .../compiler/gradle/api/CompilerSettings.kt | 4 ++ .../tools/compiler/gradle/plugin/Extension.kt | 5 +- .../gradle/plugin/LaunchSpineCompiler.kt | 69 ++++++------------- .../plugin/LaunchTaskEnvironmentSpec.kt | 53 ++++++++++---- 5 files changed, 87 insertions(+), 81 deletions(-) diff --git a/.agents/tasks/disable-protobuf-version-check.md b/.agents/tasks/disable-protobuf-version-check.md index 0e191926976..f97a1215f2c 100644 --- a/.agents/tasks/disable-protobuf-version-check.md +++ b/.agents/tasks/disable-protobuf-version-check.md @@ -39,15 +39,14 @@ relying on the exported variable, including this repo's functional tests is a convenience shortcut for the latter. - Gradle 9.8.1 (this branch's wrapper; also checked 9.7.1) `DefaultProcessForkOptions.getActualEnvironment()` converts values - with `String.valueOf()` — no `Provider` unpacking. `JavaExec.getEnvironment()` - is marked `@ToBeReplacedByLazyProperty`; once it is lazy, move the write to - configuration time. Launch tasks are realized - while the plugin is applied, before the user's `compiler { }` block runs, so - the flag must be read at execution time. -- `JavaExec.getEnvironment()` is a plain `@Internal` map (not a tracked - `Property`), so setting it in the `exec()` override does not trip the - "changing property value at execution time" deprecation addressed by - `fix-launch-task-exec-time-config`. + with `String.valueOf()` — no `Provider` unpacking, so the setting cannot be + passed to `environment` lazily (`JavaExec.getEnvironment()` is marked + `@ToBeReplacedByLazyProperty`). +- A probe showed the launch tasks are not realized while the plugins are applied, + but in the `afterEvaluate` hooks, after the build script body. So `applyDefaults()` + reads the setting at configuration time; the extension property is + `finalizeValueOnRead()`, so a change after that (early task realization, a late + `afterEvaluate`) fails loudly instead of being ignored. - `Extension` is the only implementation of `CompilerSettings` across Spine repos (`core-jvm-compiler` only calls it), so adding an interface member is safe. - Out of scope: the Gradle daemon and the `protoc` plugin processes. Their @@ -64,17 +63,19 @@ relying on the exported variable, including this repo's functional tests - [x] `CompilerSettings` (`gradle-api`): add `public val disableProtobufVersionCheck: Property` with KDoc. -- [x] `Extension` (`gradle-plugin`): implement it, not set by default. -- [x] `LaunchSpineCompiler`: - - [x] `@get:Internal internal abstract val disableProtobufVersionCheck: - Property` — internal because it does not affect the outputs. - - [x] Wire it to the extension in `applyDefaults()`. - - [x] In `exec()`, `applyProtobufVersionCheckSetting()`: `true` sets the - variable, `false` removes it, not set leaves the environment intact. +- [x] `Extension` (`gradle-plugin`): implement it, not set by default, + `finalizeValueOnRead()`. +- [x] `LaunchSpineCompiler`: no copy of the setting on the task (review by + the user). `applyDefaults()` calls + `applyProtobufVersionCheckSetting(ext.disableProtobufVersionCheck.orNull)`: + `true` sets the variable, `false` removes it, `null` leaves the environment + intact. Not a task input: the check does not change the outputs. - [x] Tests (`gradle-plugin/src/test`): - [x] `ExtensionSpec` — not set by default. - - [x] `LaunchTaskEnvironmentSpec` — not set keeps a planted inherited value; - `true` sets the variable; `false` removes a planted `true`. + - [x] `LaunchTaskEnvironmentSpec` — the extension's value reaches the task; + a change after the task is configured is rejected; `null` keeps + a planted inherited value; `true` sets the variable; `false` removes + a planted `true`. - [x] Functional test `DisableProtobufVersionCheckSpec` — `false` keeps the check even when the build sets the variable (fails with `ProtobufRuntimeVersionException`); `true` lets the Compiler run. diff --git a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt index 28c5aa6217f..84bc530cea0 100644 --- a/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt +++ b/gradle-api/src/main/kotlin/io/spine/tools/compiler/gradle/api/CompilerSettings.kt @@ -77,6 +77,10 @@ public interface CompilerSettings { * This is a shortcut for setting the variable in the environment of * the `LaunchSpineCompiler` tasks directly. * + * The tasks read the property when they are configured, which happens after + * the build script is evaluated. Set the property in the `compiler { }` block: + * once read, it cannot be changed. + * * The setting affects neither the Gradle daemon nor the `protoc` plugins. * If the check fails there, set the variable in the environment of the build instead. * diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt index 966ab69d7e0..eee22aa16c2 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Extension.kt @@ -104,10 +104,13 @@ public class Extension(private val project: Project): CompilerSettings { * Not set by default, so the Compiler process inherits the setting from * the environment of the build. * + * The value is finalized when the Compiler launch tasks read it as they are + * configured, so that a later change fails instead of being silently ignored. + * * @see CompilerSettings.disableProtobufVersionCheck */ public override val disableProtobufVersionCheck: Property = - factory.property() + factory.property().apply { finalizeValueOnRead() } /** * Obtains the source directories for the given source set. diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt index 016b3daf469..6724b033a42 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchSpineCompiler.kt @@ -167,20 +167,6 @@ public abstract class LaunchSpineCompiler : JavaExec() { @get:Internal internal abstract val protoSourceDirs: ConfigurableFileCollection - /** - * Tells whether to disable the Protobuf version check in the Compiler process. - * - * When not set, the Compiler process inherits the setting from the environment - * of the build. - * - * The property is [Internal] because disabling the check does not affect - * the generated code: the check either passes or fails the task. - * - * @see io.spine.tools.compiler.gradle.api.CompilerSettings.disableProtobufVersionCheck - */ - @get:Internal - internal abstract val disableProtobufVersionCheck: Property - @get:InputFiles @get:Classpath internal lateinit var userClasspathConfiguration: Configuration @@ -230,40 +216,12 @@ public abstract class LaunchSpineCompiler : JavaExec() { * The cleanup runs only when the task itself executes: a task that is * up-to-date, or restored from the build cache, leaves the previously * generated code intact. - * - * Applies the Protobuf version check setting of the `compiler { }` extension - * to the environment of the Compiler process. */ override fun exec() { cleanTargetDirs() - applyProtobufVersionCheckSetting() super.exec() } - /** - * Applies [disableProtobufVersionCheck] to the [PROTOBUF_VERSION_CHECK_ENV] - * environment variable of the Compiler process. - * - * Sets the variable to `true` if the property is `true`, and removes the variable - * if the property is `false`. When the property is not set, leaves the environment - * intact, so that the variable set in the environment of the build still reaches - * the Compiler. - * - * The environment is amended when the task executes rather than when it is - * configured: the property may be set after the task is configured, and Gradle - * does not evaluate providers passed as environment values. Once Gradle turns - * the environment of `JavaExec` into a lazy property, the variable can be set - * at configuration time instead. - */ - @VisibleForTesting - internal fun applyProtobufVersionCheckSetting() { - when (disableProtobufVersionCheck.orNull) { - true -> environment(PROTOBUF_VERSION_CHECK_ENV, "true") - false -> environment.remove(PROTOBUF_VERSION_CHECK_ENV) - null -> {} // Inherit the variable from the environment of the build. - } - } - /** * Deletes the existing non-empty [target][targets] directories of this task. * @@ -300,10 +258,6 @@ public abstract class LaunchSpineCompiler : JavaExec() { * Touching the task state at execution time is deprecated: querying * `Task.dependsOn` fails in Gradle 10, changing a property in Gradle 11. * - * The environment of the Compiler process is the only exception: `exec()` amends it - * via `applyProtobufVersionCheckSetting()`. The environment is a plain map - * rather than a tracked property, so the amendment is not subject to the deprecation. - * * @param sourceSet The source set for which the task is created. */ internal fun LaunchSpineCompiler.applyDefaults(sourceSet: SourceSet) { @@ -311,7 +265,7 @@ internal fun LaunchSpineCompiler.applyDefaults(sourceSet: SourceSet) { val project = project val ext = project.compilerSettings plugins = ext.plugins - disableProtobufVersionCheck.set(ext.disableProtobufVersionCheck) + applyProtobufVersionCheckSetting(ext.disableProtobufVersionCheck.orNull) compilerConfiguration = project.compilerRawArtifact userClasspathConfiguration = project.userClasspath classpath(compilerConfiguration) @@ -448,6 +402,27 @@ internal fun LaunchSpineCompiler.hasRequestFile(sourceSet: SourceSet): Boolean { return file.exists() } +/** + * Applies the given setting of the Protobuf version check to + * the [PROTOBUF_VERSION_CHECK_ENV] environment variable of the Compiler process. + * + * Sets the variable to `true` if [disableCheck] is `true`, and removes the variable + * if it is `false`. If the setting is `null`, leaves the environment intact, so that + * the variable set in the environment of the build still reaches the Compiler. + * + * @param disableCheck The value of `CompilerSettings.disableProtobufVersionCheck`, + * or `null` if it is not set. + */ +@VisibleForTesting +internal fun LaunchSpineCompiler.applyProtobufVersionCheckSetting(disableCheck: Boolean?) { + // `else` rather than `null` keeps Kotlin from adding an unreachable exhaustiveness branch. + when (disableCheck) { + true -> environment(PROTOBUF_VERSION_CHECK_ENV, "true") + false -> environment.remove(PROTOBUF_VERSION_CHECK_ENV) + else -> {} // Not set: inherit the variable from the environment of the build. + } +} + /** * The name of the environment variable which turns off the check of the code * generated by `protoc` against the version of the Protobuf runtime. diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt index 0aed01b9dc9..5f39b635fc3 100644 --- a/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/compiler/gradle/plugin/LaunchTaskEnvironmentSpec.kt @@ -15,6 +15,7 @@ package io.spine.tools.compiler.gradle.plugin import com.google.protobuf.gradle.ProtobufPlugin +import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.maps.shouldNotContainKey import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeInstanceOf @@ -30,15 +31,16 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir /** - * Verifies that [LaunchSpineCompiler] controls the variable disabling the Protobuf - * version check in the environment of the Compiler process as configured via - * [Extension.disableProtobufVersionCheck]. + * Verifies how [LaunchSpineCompiler] controls the variable disabling the Protobuf + * version check in the environment of the Compiler process. + * + * The end-to-end counterpart, with a real version check failing in the Compiler + * process, is `DisableProtobufVersionCheckSpec` in the `functionalTest` suite. */ @DisplayName("`LaunchSpineCompiler` should") internal class LaunchTaskEnvironmentSpec { private lateinit var project: Project - private lateinit var task: LaunchSpineCompiler @BeforeEach fun prepareProject(@TempDir projectDir: File) { @@ -50,40 +52,61 @@ internal class LaunchTaskEnvironmentSpec { apply() apply() } + } + + /** + * Obtains the launch task for the `main` source set, configuring it on first access. + */ + private fun launchTask(): LaunchSpineCompiler { val taskName = CompilerTaskName(SourceSetName.main).value() - // Obtaining the task configures it before the extension is changed by a test, - // as in a real build, where the task is configured before the `compiler { }` block runs. - task = project.tasks.getByName(taskName).shouldBeInstanceOf() + return project.tasks.getByName(taskName).shouldBeInstanceOf() + } + + @Test + fun `apply the setting of the extension when configured`() { + project.compilerSettings.disableProtobufVersionCheck.set(true) + + launchTask().environment[ENV_VARIABLE] shouldBe "true" } @Test - fun `leave the inherited environment intact by default`() { + fun `reject a change of the setting after the task is configured`() { + launchTask() + + shouldThrow { + project.compilerSettings.disableProtobufVersionCheck.set(true) + } + } + + @Test + fun `leave the inherited environment intact when the setting is not set`() { + val task = launchTask() // A value other than `true` tells an untouched variable from an overwritten one, // regardless of the environment of the machine running the test. val inherited = "inherited-from-build" task.environment(ENV_VARIABLE, inherited) - task.applyProtobufVersionCheckSetting() + task.applyProtobufVersionCheckSetting(null) task.environment[ENV_VARIABLE] shouldBe inherited } @Test - fun `disable the Protobuf version check when the extension says 'true'`() { - project.compilerSettings.disableProtobufVersionCheck.set(true) + fun `disable the Protobuf version check when the setting is 'true'`() { + val task = launchTask() - task.applyProtobufVersionCheckSetting() + task.applyProtobufVersionCheckSetting(true) task.environment[ENV_VARIABLE] shouldBe "true" } @Test - fun `keep the Protobuf version check when the extension says 'false'`() { + fun `keep the Protobuf version check when the setting is 'false'`() { + val task = launchTask() // As if the variable were set in the environment of the build. task.environment(ENV_VARIABLE, "true") - project.compilerSettings.disableProtobufVersionCheck.set(false) - task.applyProtobufVersionCheckSetting() + task.applyProtobufVersionCheckSetting(false) task.environment shouldNotContainKey ENV_VARIABLE } From f8f671749f6008bc50e9515e7d7d9bd0b23ae19c Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 19 Oct 2026 21:23:29 +0100 Subject: [PATCH 10/10] Let the end-to-end spec control the variable in the fork The setting is now applied by the first configuration action of the task, so the fixture's own `environment.remove(...)` would override it. The fixture keeps the variable of the build when `keepVersionCheckVariable` is set, which `DisableProtobufVersionCheckSpec` does: - `false` runs with the variable exported for the build; - `true` runs with no variable in the environment of the build. So in each case only the setting under test changes the outcome. Co-Authored-By: Claude Opus 5.5 --- .../plugin/DisableProtobufVersionCheckSpec.kt | 68 ++++++++----------- .../protobuf-runtime-test/build.gradle.kts | 7 +- 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt b/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt index d9c3e56ad50..793b7c7e452 100644 --- a/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt +++ b/gradle-plugin/src/functionalTest/kotlin/io/spine/tools/compiler/gradle/plugin/DisableProtobufVersionCheckSpec.kt @@ -38,12 +38,14 @@ import org.junit.jupiter.api.io.TempDir * Verifies that `compiler { disableProtobufVersionCheck }` controls the Protobuf * gencode/runtime version check in the JVM forked by [LaunchSpineCompiler]. * - * The tests use the `protobuf-runtime-test` fixture of [ProtobufRuntimeSpec], which turns - * the check back on in the forked JVM. The plugin of the fixture is built with a Protobuf - * release newer than the runtime of the CLI. Each test forces the runtime of the CLI - * configuration, which comes first on the classpath of the forked JVM, to stay at the CLI's - * own version. So the gencode of the plugin finds a runtime older than itself, as in a build - * that forces an older Protobuf runtime. + * The tests use the `protobuf-runtime-test` fixture of [ProtobufRuntimeSpec]. The plugin + * of the fixture is built with a Protobuf release newer than the runtime of the CLI. + * Each test forces the runtime of the CLI configuration, which comes first on the classpath + * of the forked JVM, to stay at the CLI's own version. So the gencode of the plugin finds + * a runtime older than itself, as in a build that forces an older Protobuf runtime. + * + * Unlike [ProtobufRuntimeSpec], the tests ask the fixture to keep the variable of the build + * in the forked JVM, so that only the setting under test changes it. */ @SlowTest @DisplayName("`disableProtobufVersionCheck` should") @@ -63,20 +65,8 @@ internal class DisableProtobufVersionCheckSpec { @Test fun `keep the check when set to 'false', even if the build disables it`() { - val project = createProject( - """ - // Put the variable back, as if it were set in the environment of the build. - tasks.withType().configureEach { - environment("$VERSION_CHECK_VARIABLE", "true") - } - - spine { - compiler { - disableProtobufVersionCheck.set(false) - } - } - """ - ) + // `tuneRunner()` sets the variable for the whole build, as a user may do. + val project = createProject(disableCheck = false) val result = project.executeAndFail(launchSpineCompiler) @@ -86,15 +76,9 @@ internal class DisableProtobufVersionCheckSpec { @Test fun `turn the check off when set to 'true'`() { - val project = createProject( - """ - spine { - compiler { - disableProtobufVersionCheck.set(true) - } - } - """ - ) + val project = createProject(disableCheck = true) + // Drop the variable set by `tuneRunner()`, so that only the setting turns the check off. + project.runner.withEnvironment(emptyMap()) val result = project.executeTask(launchSpineCompiler) @@ -105,14 +89,14 @@ internal class DisableProtobufVersionCheckSpec { * Creates the fixture project with the plugin built on [NEWER_PROTOBUF]. * * Appends to the build script of the project the code that forces the runtime of - * the CLI configuration to [CLI_PROTOBUF], followed by the given [caseSetup]. + * the CLI configuration to [CLI_PROTOBUF], and sets the property under test. * A `force` wins over the constraints the Compiler Gradle plugin derives from * the user classpath, so the newer runtime of the plugin stays behind the CLI's one * on the classpath of the forked JVM. * - * @param caseSetup The build script code setting up the test case. + * @param disableCheck The value to set to the `disableProtobufVersionCheck` property. */ - private fun createProject(caseSetup: String): GradleProject { + private fun createProject(disableCheck: Boolean): GradleProject { val project = GradleProject.setupAt(projectDir) .fromResources("protobuf-runtime-test") .withSharedTestKitDirectory() @@ -123,19 +107,21 @@ internal class DisableProtobufVersionCheckSpec { .copyBuildSrc() .create() project.tuneRunner() - val forceCliRuntime = """ + projectDir.resolve("gradle.properties") + .appendText("\nkeepVersionCheckVariable=true\n") + val caseSetup = """ configurations.named("$COMPILER_RAW_ARTIFACT") { resolutionStrategy.force("com.google.protobuf:protobuf-java:$CLI_PROTOBUF") } + + spine { + compiler { + disableProtobufVersionCheck.set($disableCheck) + } + } """ - projectDir.resolve("build.gradle.kts").appendText( - "\n" + forceCliRuntime.trimIndent() + "\n\n" + caseSetup.trimIndent() + "\n" - ) + projectDir.resolve("build.gradle.kts") + .appendText("\n" + caseSetup.trimIndent() + "\n") return project } } - -/** - * The name of the variable checked by the Protobuf runtime. - */ -private const val VERSION_CHECK_VARIABLE = "TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK" diff --git a/gradle-plugin/src/functionalTest/resources/protobuf-runtime-test/build.gradle.kts b/gradle-plugin/src/functionalTest/resources/protobuf-runtime-test/build.gradle.kts index 93338e91bd6..6e4c2f7baba 100644 --- a/gradle-plugin/src/functionalTest/resources/protobuf-runtime-test/build.gradle.kts +++ b/gradle-plugin/src/functionalTest/resources/protobuf-runtime-test/build.gradle.kts @@ -55,11 +55,16 @@ spine { } } +// Set by a test that controls the version check variable via the `compiler { }` extension. +val keepVersionCheckVariable = providers.gradleProperty("keepVersionCheckVariable").isPresent + tasks.withType().configureEach { // The functional tests turn off the Protobuf gencode/runtime version check // for the whole build. Turn it back on in the Compiler JVM, where the gencode // of the plugin must not find a runtime older than itself. - environment.remove("TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK") + if (!keepVersionCheckVariable) { + environment.remove("TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK") + } // Record the classpath of the Compiler JVM, letting the functional test // check which Protobuf runtime comes first. val classpathFile = layout.projectDirectory.file("compiler-classpath.txt")