diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt index 49dd562eb..5439c17a5 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt @@ -34,7 +34,7 @@ package io.spine.dependency.local @Suppress("ConstPropertyName", "unused") object ToolBase { const val group = Spine.toolsGroup - const val version = "2.0.0-SNAPSHOT.364" + const val version = "2.0.0-SNAPSHOT.366" const val dogfoodingVersion = "2.0.0-SNAPSHOT.361" const val lib = "$group:tool-base:$version" diff --git a/config b/config index c2504f246..3b2520161 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit c2504f24673ac232481a8b59352707d0443b0efd +Subproject commit 3b25201619108ead402e4adaf15056378f8f4473 diff --git a/dependencies.md b/dependencies.md index a8818535c..28dd281b1 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:compiler-api:2.0.0-SNAPSHOT.027` +# Dependencies of `io.spine.tools:compiler-api:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -1143,14 +1143,14 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-api-tests:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 13.0. @@ -1993,14 +1993,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-backend:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -3147,14 +3147,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-cli:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -4350,14 +4350,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-gradle-api:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -5402,14 +5402,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-gradle-plugin:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -6502,14 +6502,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-jvm:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -7673,14 +7673,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-params:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -8815,14 +8815,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-protoc-plugin:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -9679,14 +9679,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-test-env:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -10829,14 +10829,14 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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.027` +# Dependencies of `io.spine.tools:compiler-testlib:2.0.0-SNAPSHOT.028` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -12086,6 +12086,6 @@ This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Sun Oct 19 18:21:02 WEST 2025** using +This report was generated on **Tue Oct 21 00:14:55 WEST 2025** 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/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/ConfigureIdea.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/ConfigureIdea.kt index ea52b9acf..fc80101c1 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/ConfigureIdea.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/ConfigureIdea.kt @@ -29,10 +29,8 @@ package io.spine.tools.compiler.gradle.plugin import com.google.protobuf.gradle.GenerateProtoTask import io.spine.tools.compiler.gradle.api.builtins import io.spine.tools.compiler.gradle.api.debug -import io.spine.tools.compiler.gradle.api.plugins import io.spine.tools.compiler.gradle.api.generatedDir -import io.spine.tools.protobuf.gradle.generatedSourceProtoDir -import java.io.File +import io.spine.tools.compiler.gradle.api.plugins import java.nio.file.Path import java.nio.file.Paths import kotlin.io.path.Path @@ -47,7 +45,7 @@ import org.gradle.plugins.ide.idea.model.IdeaModule * not included in the IDEA project. * * IDEA should only see the sources generated by the Compiler as - * we define in [GenerateProtoTask.configureSourceSetDirs]. + * we define in [io.spine.tools.protobuf.gradle.plugin.configureSourceSetDirs]. */ internal fun Project.configureIdea() { afterEvaluate { @@ -77,15 +75,6 @@ private fun IdeaModule.setupDirectories(project: Project) { excludeExtractedDirs(project) } -/** - * Obtains the root directory into which Protobuf Gradle Plugin assigns the `protoc` output. - * - * This is an alias for [io.spine.tools.gradle.protobuf.generatedSourceProtoDir] which - * also returns [File] instead of [Path]. - */ -private val Project.protocOutputDir: File - get() = generatedSourceProtoDir.toFile() - /** * Traverses [generatedSourceDirs][IdeaModule.generatedSourceDirs] excluding those * belonging to `protoc` output directory. 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 6966e2ff1..e9323cc3e 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 @@ -32,7 +32,6 @@ import io.spine.tools.compiler.gradle.api.Names.EXTENSION_NAME import io.spine.tools.compiler.gradle.plugin.Extension.Companion.defaultSubdirectories import io.spine.tools.fs.DirectoryName.generated import io.spine.tools.gradle.DslSpec -import io.spine.tools.protobuf.gradle.generatedSourceProtoDir import org.gradle.api.Project import org.gradle.api.file.Directory import org.gradle.api.file.DirectoryProperty @@ -64,13 +63,13 @@ public class Extension(private val project: Project): CompilerSettings { /** * Synthetic property for providing the source directories for the given - * source set under [Project.generatedSourceProtoDir]. + * source set under [Project.protocOutputDir]. * * @see sourceDirs */ private val srcBaseDirProperty: DirectoryProperty = with(project) { objects.directoryProperty().convention(provider { - layout.projectDirectory.dir(generatedSourceProtoDir.toString()) + layout.projectDirectory.dir(protocOutputDir.toString()) }) } diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Paths.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Paths.kt index 1904b1c86..9123ff0e8 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Paths.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Paths.kt @@ -26,8 +26,19 @@ package io.spine.tools.compiler.gradle.plugin +import io.spine.tools.protobuf.gradle.protobufExtension import java.io.File import java.nio.file.Path +import org.gradle.api.Project + +/** + * Obtains the root directory into which Protobuf Gradle Plugin assigns the `protoc` output. + */ +internal val Project.protocOutputDir: File + get() { + val path = protobufExtension!!.generatedFilesBaseDir + return File(path) + } /** * Obtains a list of directories resolved as nested into this one. diff --git a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Plugin.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Plugin.kt index 3fff15e2b..d3b0b383b 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Plugin.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/compiler/gradle/plugin/Plugin.kt @@ -49,24 +49,19 @@ import io.spine.tools.compiler.gradle.api.ProtocPluginArtifact import io.spine.tools.compiler.gradle.api.SpineCompilerCleanTask import io.spine.tools.compiler.gradle.api.compilerWorkingDir import io.spine.tools.compiler.gradle.api.generatedDir -import io.spine.tools.compiler.gradle.plugin.GeneratedSubdir.GRPC -import io.spine.tools.compiler.gradle.plugin.GeneratedSubdir.JAVA -import io.spine.tools.compiler.gradle.plugin.GeneratedSubdir.KOTLIN import io.spine.tools.compiler.params.WorkingDirectory import io.spine.tools.gradle.lib.LibraryPlugin import io.spine.tools.gradle.lib.spineExtension -import io.spine.tools.gradle.project.hasJava import io.spine.tools.gradle.project.hasJavaOrKotlin -import io.spine.tools.gradle.project.hasKotlin import io.spine.tools.gradle.project.sourceSets -import io.spine.tools.gradle.task.findKotlinDirectorySet import io.spine.tools.meta.ArtifactMeta import io.spine.tools.meta.MavenArtifact +import io.spine.tools.protobuf.gradle.GeneratedDirectoryContext import io.spine.tools.protobuf.gradle.plugin.DescriptorSetFilePlugin +import io.spine.tools.protobuf.gradle.plugin.configureSourceSetDirs import io.spine.tools.protobuf.gradle.protobufExtension -import java.io.File +import java.nio.file.Path import org.gradle.api.Project -import org.gradle.api.file.SourceDirectorySet import org.gradle.api.tasks.Delete import org.gradle.api.tasks.SourceSet import org.gradle.api.tasks.TaskProvider @@ -101,7 +96,7 @@ import org.gradle.kotlin.dsl.register */ public class Plugin : LibraryPlugin( CompilerDslSpec() -) { +), GeneratedDirectoryContext { init { // Inject the access to the project so that `CompilerDslSpec` can @@ -122,6 +117,12 @@ public class Plugin : LibraryPlugin( } } + override fun generatedDir( + project: Project, + sourceSet: SourceSet, + language: String + ): Path = project.generatedDir.resolve("${sourceSet.name}/$language") + public companion object { /** @@ -235,6 +236,7 @@ private fun Project.setProtocArtifact() { } } +context(_: GeneratedDirectoryContext) private fun Project.configureWithProtobufPlugin(compilerVersion: String) { val protocPlugin = ProtocPluginArtifact(compilerVersion) pluginManager.withPlugin(PROTOBUF_GRADLE_PLUGIN_ID) { @@ -264,6 +266,7 @@ private fun Project.setProtocPluginArtifact(protocPlugin: ProtocPluginArtifact) * Configures the `GenerateProtoTaskCollection` by adding a configuration action for * each of the tasks. */ +context(_: GeneratedDirectoryContext) private fun Project.configureGenerateProtoTasks() { protobufExtension?.apply { /* The below block adds a configuration action for the `GenerateProtoTaskCollection`. @@ -288,6 +291,7 @@ private fun Project.configureGenerateProtoTasks() { * @see [GenerateProtoTask.configureSourceSetDirs] * @see [Project.handleLaunchTaskDependency] */ +context(_: GeneratedDirectoryContext) private fun Project.configureProtoTask(task: GenerateProtoTask) { if (hasJavaOrKotlin()) { task.builtins.maybeCreate("kotlin") @@ -316,78 +320,6 @@ private fun GenerateProtoTask.addProtocPlugin() { } } -/** - * The names of the subdirectories where the Compiler places generated files. - */ -private object GeneratedSubdir { - const val JAVA = "java" - const val KOTLIN = "kotlin" - const val GRPC = "grpc" -} - -/** - * Exclude [GenerateProtoTask.outputBaseDir] from Java source set directories to avoid - * duplicated source code files. - * - * Adds the `generated` directory to the Java and Kotlin source sets instead. - */ -private fun GenerateProtoTask.configureSourceSetDirs() { - val project = project - val protocOutputDir = File(outputBaseDir).parentFile - - /** Filters out directories belonging to `build/generated/source/proto`. */ - fun excludeFor(lang: SourceDirectorySet) { - val newSourceDirectories = lang.sourceDirectories - .filter { !it.residesIn(protocOutputDir) } - .toSet() - - // Clear the source directories of the Java source set. - // This trick was needed when building the `base` module of Spine. - // Otherwise, the `java` plugin would complain about duplicate source files. - lang.setSrcDirs(listOf()) - - // Add the filtered directories back to the Java source set. - lang.srcDirs(newSourceDirectories) - } - - val sourceSet = sourceSet - - if (project.hasJava()) { - val java = sourceSet.java - excludeFor(java) - - java.srcDir(generatedDir(JAVA)) - - // Add the `grpc` directory unconditionally. - // We may not have all the `protoc` plugins configured for the task at this time. - // So, we cannot check if the `grpc` plugin is enabled. - // It is safe to add the directory anyway, because `srcDir()` does not require - // the directory to exist. - java.srcDir(generatedDir(GRPC)) - } - - fun SourceDirectorySet.setup() { - excludeFor(this@setup) - srcDirs(generatedDir(KOTLIN)) - } - - if (project.hasKotlin()) { - val kotlinDirectorySet = sourceSet.findKotlinDirectorySet() - kotlinDirectorySet?.setup() - ?: project.afterEvaluate { - sourceSet.findKotlinDirectorySet()?.setup() - } - } -} - -/** - * Obtains the `generated` directory for the source set of the task. - * - * If [language] is specified returns the subdirectory for this language. - */ -private fun GenerateProtoTask.generatedDir(language: String = ""): File = - project.generatedDir(sourceSet, language) - /** * Makes a [LaunchSpineCompiler], if it exists for the source set of the given [GenerateProtoTask], * depend on this task. diff --git a/pom.xml b/pom.xml index c149258f9..dcc749d68 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.tools spine-compiler -2.0.0-SNAPSHOT.027 +2.0.0-SNAPSHOT.028 2015 @@ -47,12 +47,6 @@ all modules and does not describe the project structure per-subproject. 3.5.2 compile - - com.google.auto.service - auto-service-annotations - 1.1.1 - compile - com.google.protobuf protobuf-java @@ -140,25 +134,25 @@ all modules and does not describe the project structure per-subproject. io.spine.tools gradle-plugin-api - 2.0.0-SNAPSHOT.364 + 2.0.0-SNAPSHOT.366 compile io.spine.tools jvm-tools - 2.0.0-SNAPSHOT.364 + 2.0.0-SNAPSHOT.366 compile io.spine.tools plugin-base - 2.0.0-SNAPSHOT.364 + 2.0.0-SNAPSHOT.366 compile io.spine.tools protobuf-setup-plugins - 2.0.0-SNAPSHOT.364 + 2.0.0-SNAPSHOT.366 compile @@ -170,13 +164,13 @@ all modules and does not describe the project structure per-subproject. io.spine.tools psi-java - 2.0.0-SNAPSHOT.364 + 2.0.0-SNAPSHOT.366 compile io.spine.tools tool-base - 2.0.0-SNAPSHOT.364 + 2.0.0-SNAPSHOT.366 compile @@ -236,7 +230,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools plugin-testlib - 2.0.0-SNAPSHOT.364 + 2.0.0-SNAPSHOT.366 test @@ -299,6 +293,12 @@ all modules and does not describe the project structure per-subproject. 5.13.2 test + + com.google.auto.service + auto-service-annotations + 1.1.1 + provided + com.google.devtools.ksp symbol-processing diff --git a/version.gradle.kts b/version.gradle.kts index 77272c06d..dcaab4946 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`. */ -val compilerVersion: String by extra("2.0.0-SNAPSHOT.027") +val compilerVersion: String by extra("2.0.0-SNAPSHOT.028") /** * The version, same as [compilerVersion], which is used for publishing