diff --git a/.agents/tasks/938-move-codegen-request-writer.md b/.agents/tasks/938-move-codegen-request-writer.md new file mode 100644 index 0000000000..476ce91fc8 --- /dev/null +++ b/.agents/tasks/938-move-codegen-request-writer.md @@ -0,0 +1,46 @@ +--- +slug: 938-move-codegen-request-writer +branch: claude/busy-dirac-wwflbm +owner: claude +status: in-progress +started: 2026-06-10 +--- + +## Goal + +`io.spine.code.proto.CodeGeneratorRequestWriter` is removed from `base` +(it is protoc-plugin tooling, not runtime API), and the build is green. +Closes [#938](https://github.com/SpineEventEngine/base-libraries/issues/938) +together with the receiving change in `tool-base`. + +## Context + +- The class moves to the `tool-base` module of the ToolBase repository under + `io.spine.tools.code.proto` (same-named branch there). +- The only consumers are the protoc-plugin entry points of the Compiler and + ProtoTap; they migrate by switching the import once both PRs are published. +- `CodeGeneratorRequestParsingSpec.kt` and `CodeGeneratorRequestsJavaSpec.java` + stay: they test `io.spine.type` parsing APIs which remain in `base`, and the + Java spec still uses the `constructRequest` helper declared in the former. +- Removing public API is a breaking change: the snapshot version advances to + the next multiple of 10. + +## Plan + +- [x] Remove `base/src/main/kotlin/io/spine/code/proto/CodeGeneratorRequestWriter.kt`. +- [x] Remove `base/src/test/kotlin/io/spine/code/proto/CodeGeneratorRequestWriterSpec.kt`. +- [x] Bump version `2.0.0-SNAPSHOT.404` -> `2.0.0-SNAPSHOT.410` (breaking). +- [ ] `./gradlew build` green; commit regenerated dependency reports if any. + - Blocked in the sandbox: all Spine artifact repositories return 403 for + the buildscript dependency `io.spine.tools:protobuf-setup-plugins`, so + no Gradle build can run here at all. Verification is delegated to PR CI. + - Repo-wide greps confirm no remaining references to the removed class; + the surviving `CodeGeneratorRequest*` specs do not use it. +- [x] Push and open a draft PR; merge after the tool-base PR. + +## Log + +- 2026-06-10 — drafted; executing autonomously per issue #938. +- 2026-06-10 — removal committed and version bumped; sandbox cannot resolve + Spine snapshot artifacts (403 on all repos), so the build runs on PR CI + instead. diff --git a/base/src/main/kotlin/io/spine/code/proto/CodeGeneratorRequestWriter.kt b/base/src/main/kotlin/io/spine/code/proto/CodeGeneratorRequestWriter.kt deleted file mode 100644 index afa339f294..0000000000 --- a/base/src/main/kotlin/io/spine/code/proto/CodeGeneratorRequestWriter.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2024, 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.code.proto - -import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest -import io.spine.io.replaceExtension -import io.spine.string.decodeBase64 -import io.spine.type.ExtensionRegistryHolder.extensionRegistry -import io.spine.type.parse -import io.spine.type.toJson -import java.io.File -import java.io.InputStream -import java.nio.file.StandardOpenOption.CREATE -import java.nio.file.StandardOpenOption.TRUNCATE_EXISTING -import kotlin.io.path.writeBytes - -/** - * Parses a [CodeGeneratorRequest] from given [input] and writes it into - * files in [binary][writeBinary] and [JSON][writeJson] format. - * - * @param input The input stream containing binary version of the request. - */ -public class CodeGeneratorRequestWriter( - private val input: InputStream -) { - /** - * Lazily evaluated [CodeGeneratorRequest] parsed from [input] using [extensionRegistry]. - */ - public val request: CodeGeneratorRequest by lazy { - CodeGeneratorRequest::class.parse(input) - } - - /** - * The target file for writing the request in the binary form. - * - * The name of the request is passed as the [parameter][CodeGeneratorRequest.getParameter] of - * the request as a Base64 encoded file path. - */ - public val requestFile: File by lazy { - File(request.parameter.decodeBase64()) - } - - /** - * The path to the request file in JSON format. - * - * The file has the same name as [requestFile] and the extension of `".pb.json"`. - */ - public val requestFileInJson: File by lazy { - requestFile.replaceExtension("pb.json") - } - - /** - * Writes the request into the location specified in [requestFile]. - */ - public fun writeBinary() { - ensureDirectory() - requestFile.toPath().writeBytes(request.toByteArray(), CREATE, TRUNCATE_EXISTING) - } - - /** - * Writes the request in JSON format to the location specified in [requestFileInJson]. - */ - public fun writeJson() { - val json = request.toJson() - ensureDirectory() - requestFileInJson.writeText(json) - } - - private fun ensureDirectory() { - val targetDir = requestFile.parentFile - targetDir.mkdirs() - } -} diff --git a/base/src/test/kotlin/io/spine/code/proto/CodeGeneratorRequestWriterSpec.kt b/base/src/test/kotlin/io/spine/code/proto/CodeGeneratorRequestWriterSpec.kt deleted file mode 100644 index e85231b8d1..0000000000 --- a/base/src/test/kotlin/io/spine/code/proto/CodeGeneratorRequestWriterSpec.kt +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2024, 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.code.proto - -import io.kotest.matchers.shouldBe -import io.spine.io.replaceExtension -import io.spine.string.toBase64Encoded -import java.io.File -import java.io.InputStream -import java.nio.file.Path -import kotlin.io.path.inputStream -import kotlin.io.path.writeBytes -import org.junit.jupiter.api.AfterEach -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 - -@DisplayName("`CodeGeneratorRequestWriter` should") -internal class CodeGeneratorRequestWriterSpec { - - private lateinit var requestFile: File - private lateinit var writer: CodeGeneratorRequestWriter - private lateinit var input: InputStream - - @BeforeEach - fun prepareInput(@TempDir dir: Path) { - val inputFile = dir.resolve("input.stream") - // Request the file in the directory which does not exist. - requestFile = dir.resolve("nested/request.binbp").toFile() - val request = constructRequest(requestFile.absolutePath.toBase64Encoded()) - inputFile.writeBytes(request.toByteArray()) - input = inputFile.inputStream() - writer = CodeGeneratorRequestWriter(input) - } - - @AfterEach - fun closeInput() { - input.close() - } - - @Test - fun `write binary version of the request`() { - writer.writeBinary() - requestFile.exists() shouldBe true - } - - @Test - fun `write JSON version of the request`() { - writer.writeJson() - requestFile.replaceExtension("pb.json").exists() shouldBe true - } -} diff --git a/docs/dependencies/dependencies.md b/docs/dependencies/dependencies.md index cb32f01cab..f4f908f261 100644 --- a/docs/dependencies/dependencies.md +++ b/docs/dependencies/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-annotations:2.0.0-SNAPSHOT.404` +# Dependencies of `io.spine:spine-annotations:2.0.0-SNAPSHOT.410` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 26.1.0. @@ -767,7 +767,7 @@ This report was generated on **Mon Jun 08 18:37:28 WEST 2026** using -# Dependencies of `io.spine:spine-base:2.0.0-SNAPSHOT.404` +# Dependencies of `io.spine:spine-base:2.0.0-SNAPSHOT.410` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -1611,7 +1611,7 @@ This report was generated on **Mon Jun 08 18:37:29 WEST 2026** using -# Dependencies of `io.spine:spine-environment:2.0.0-SNAPSHOT.404` +# Dependencies of `io.spine:spine-environment:2.0.0-SNAPSHOT.410` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -2437,7 +2437,7 @@ This report was generated on **Mon Jun 08 18:37:28 WEST 2026** using -# Dependencies of `io.spine:spine-format:2.0.0-SNAPSHOT.404` +# Dependencies of `io.spine:spine-format:2.0.0-SNAPSHOT.410` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0. diff --git a/docs/dependencies/pom.xml b/docs/dependencies/pom.xml index c487c5f049..df9b10ba9b 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 base-libraries -2.0.0-SNAPSHOT.404 +2.0.0-SNAPSHOT.410 2015 diff --git a/version.gradle.kts b/version.gradle.kts index c5226ba68a..36a5dde535 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -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. @@ -24,4 +24,4 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -val versionToPublish: String by extra("2.0.0-SNAPSHOT.404") +val versionToPublish: String by extra("2.0.0-SNAPSHOT.410")