diff --git a/buildSrc/src/main/kotlin/module.gradle.kts b/buildSrc/src/main/kotlin/module.gradle.kts index 5aa972f..1d87db5 100644 --- a/buildSrc/src/main/kotlin/module.gradle.kts +++ b/buildSrc/src/main/kotlin/module.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2023, TeamDev. All rights reserved. + * 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. @@ -90,8 +90,6 @@ fun Module.addDependencies() { compileOnlyApi(CheckerFramework.annotations) ErrorProne.annotations.forEach { compileOnlyApi(it) } -// implementation(Guava.lib) - testImplementation(Guava.testLib) JUnit.api.forEach { testImplementation(it) } Truth.libs.forEach { testImplementation(it) } @@ -165,5 +163,3 @@ fun Module.configureGitHubPages() { rootFolder.set(rootDir) } } - - diff --git a/dependencies.md b/dependencies.md index edd6138..a6b0782 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:prototap-api:0.8.2` +# Dependencies of `io.spine.tools:prototap-api:0.8.3` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 24.0.1. @@ -480,12 +480,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu May 02 19:21:13 WEST 2024** 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). +This report was generated on **Fri May 03 12:02:06 WEST 2024** 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:prototap-gradle-plugin:0.8.2` +# Dependencies of `io.spine.tools:prototap-gradle-plugin:0.8.3` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -1243,12 +1243,12 @@ This report was generated on **Thu May 02 19:21:13 WEST 2024** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu May 02 19:21:14 WEST 2024** 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). +This report was generated on **Fri May 03 12:02:06 WEST 2024** 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:prototap-protoc-plugin:0.8.2` +# Dependencies of `io.spine.tools:prototap-protoc-plugin:0.8.3` ## Runtime 1. **Group** : com.google.protobuf. **Name** : protobuf-java. **Version** : 3.25.1. @@ -1732,4 +1732,4 @@ This report was generated on **Thu May 02 19:21:14 WEST 2024** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu May 02 19:21:14 WEST 2024** 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 +This report was generated on **Fri May 03 12:02:06 WEST 2024** 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/prototap/gradle/Plugin.kt b/gradle-plugin/src/main/kotlin/io/spine/tools/prototap/gradle/Plugin.kt index 7b02d21..233d223 100644 --- a/gradle-plugin/src/main/kotlin/io/spine/tools/prototap/gradle/Plugin.kt +++ b/gradle-plugin/src/main/kotlin/io/spine/tools/prototap/gradle/Plugin.kt @@ -127,14 +127,23 @@ private val protocPlugin: Artifact by lazy { } } +/** + * Configures [GenerateProtoTask] for the source set specified in the [Extension.sourceSet]. + * + * The task is configured to in the following ways: + * 1. As an input for `processTaskResources`. + * This way all the generated source code becomes resources for the `test` source set. + * 2. Adds ProtoTap `protoc` plugin. + * 3. Instructs to generate descriptor set file, if [Extension.generateDescriptorSet] + * property is set to `true`. + */ private fun Project.tuneProtoTasks() { - val sourceSetName = extension.sourceSet.get().name - /* The below block adds a configuration action for the `GenerateProtoTaskCollection`. We cannot do it like `generateProtoTasks.all().forEach { ... }` because it breaks the configuration order of the `GenerateProtoTaskCollection`. This, in turn, leads to missing generated sources in the `compileJava` task. */ protobufExtension?.generateProtoTasks { + val sourceSetName = extension.sourceSet.get().name it.ofSourceSet(sourceSetName).configureEach { task -> tasks.processTestResources.run { copySourcesFrom(task.outputBaseDir) diff --git a/gradle-plugin/src/test/kotlin/io/spine/tools/prototap/gradle/PluginSpec.kt b/gradle-plugin/src/test/kotlin/io/spine/tools/prototap/gradle/PluginSpec.kt index f245323..028604c 100644 --- a/gradle-plugin/src/test/kotlin/io/spine/tools/prototap/gradle/PluginSpec.kt +++ b/gradle-plugin/src/test/kotlin/io/spine/tools/prototap/gradle/PluginSpec.kt @@ -90,6 +90,14 @@ internal class PluginSpec { assertRequestFileExits() } + @Test + fun `run when plugin is added before 'java-test-fixtures'`() { + createProject("before-test-fixtures") + runBuild() + assertJavaCodeGenerated() + assertRequestFileExits() + } + private fun assertJavaCodeGenerated() { val javaDir = resultDir.resolve("java") javaDir.countFiles() shouldNotBe 0 diff --git a/gradle-plugin/src/test/resources/before-test-fixtures/build.gradle.kts b/gradle-plugin/src/test/resources/before-test-fixtures/build.gradle.kts new file mode 100644 index 0000000..c18be1f --- /dev/null +++ b/gradle-plugin/src/test/resources/before-test-fixtures/build.gradle.kts @@ -0,0 +1,58 @@ +/* + * 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 + * + * http://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. + */ + +import com.google.protobuf.gradle.protobuf +import io.spine.internal.dependency.Protobuf +import io.spine.internal.dependency.GoogleApis +import io.spine.internal.gradle.standardToSpineSdk + +buildscript { + standardSpineSdkRepositories() +} + +plugins { + java + id("com.google.protobuf") + id("@PROTOTAP_PLUGIN_ID@") version "@PROTOTAP_VERSION@" + `java-test-fixtures` +} + +repositories { + mavenLocal() + standardToSpineSdk() +} + +protobuf { + protoc { + artifact = io.spine.internal.dependency.Protobuf.compiler + } +} + +dependencies { + testFixturesImplementation(Protobuf.javaLib) + // For `google/type/` proto types used in stub domains. + testFixturesImplementation(GoogleApis.commonProtos) +} diff --git a/gradle-plugin/src/test/resources/before-test-fixtures/settings.gradle.kts b/gradle-plugin/src/test/resources/before-test-fixtures/settings.gradle.kts new file mode 100644 index 0000000..4aadfdd --- /dev/null +++ b/gradle-plugin/src/test/resources/before-test-fixtures/settings.gradle.kts @@ -0,0 +1,31 @@ +/* + * 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 + * + * http://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. + */ + +pluginManagement { + repositories { + mavenLocal() + } +} diff --git a/gradle-plugin/src/test/resources/with-settings/src/test/proto/given/domain/gas_transportation.proto b/gradle-plugin/src/test/resources/before-test-fixtures/src/testFixtures/proto/given/domain/gas_transportation.proto similarity index 100% rename from gradle-plugin/src/test/resources/with-settings/src/test/proto/given/domain/gas_transportation.proto rename to gradle-plugin/src/test/resources/before-test-fixtures/src/testFixtures/proto/given/domain/gas_transportation.proto diff --git a/gradle-plugin/src/test/resources/with-settings/src/test/proto/given/domain/oil_refinery.proto b/gradle-plugin/src/test/resources/before-test-fixtures/src/testFixtures/proto/given/domain/oil_refinery.proto similarity index 100% rename from gradle-plugin/src/test/resources/with-settings/src/test/proto/given/domain/oil_refinery.proto rename to gradle-plugin/src/test/resources/before-test-fixtures/src/testFixtures/proto/given/domain/oil_refinery.proto diff --git a/gradle-plugin/src/test/resources/with-settings/build.gradle.kts b/gradle-plugin/src/test/resources/with-settings/build.gradle.kts index 6349ead..7c14c08 100644 --- a/gradle-plugin/src/test/resources/with-settings/build.gradle.kts +++ b/gradle-plugin/src/test/resources/with-settings/build.gradle.kts @@ -51,26 +51,11 @@ protobuf { } } -dependencies { - testImplementation(Protobuf.javaLib) - // For `google/type/` proto types used in stub domains. - testImplementation(GoogleApis.commonProtos) -} - - @Suppress( "UnstableApiUsage" /* testing suites feature */ ) testing { suites { - val test by getting(JvmTestSuite::class) { - useJUnitJupiter(JUnit.version) - dependencies { - implementation(Protobuf.javaLib) - implementation(GoogleApis.commonProtos) - } - } - val functionalTest by registering(JvmTestSuite::class) { useJUnitJupiter(JUnit.version) dependencies { @@ -87,3 +72,10 @@ prototap { sourceSet.set(functionalTest) generateDescriptorSet.set(true) } + +// Force Gradle to execute the `generateFunctionalTestProto` task, which otherwise +// "hang in the air" without dependencies because we don't have `main` and `test` source sets. +val generateFunctionalTestProto by tasks.getting +tasks.check { + dependsOn(generateFunctionalTestProto) +} diff --git a/gradle-plugin/src/test/resources/with-settings/src/functionalTest/proto/given/domain/gas_transportation.proto b/gradle-plugin/src/test/resources/with-settings/src/functionalTest/proto/given/domain/gas_transportation.proto new file mode 100644 index 0000000..a796651 --- /dev/null +++ b/gradle-plugin/src/test/resources/with-settings/src/functionalTest/proto/given/domain/gas_transportation.proto @@ -0,0 +1,65 @@ +/* +* Copyright 2024, TeamDev. All rights reserved. +* +* 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. +*/ +syntax = "proto3"; + +package given.domain; + +// +// This is a "vanilla" Protobuf file, which does not use Spine-specific features like +// custom options such as `type_url_prefix` or validation constraints. +// We also use "pure" Protobuf Java `protoc` plugin to process these files so that +// we recreate conditions we have before ProtoData gets into play after `protoc` +// finishes its work. +// + +option java_package = "io.spine.given.domain.gas"; +option java_outer_classname = "GasTransportationProto"; +option java_multiple_files = true; + +import "google/type/latlng.proto"; + +message OilAndGasWell { + google.type.LatLng location = 1; +} + +message Pipe { + google.type.LatLng from = 1; + google.type.LatLng to = 2; +} + +message GasProcessingPlant { + string name = 1; + google.type.LatLng location = 2; + repeated Pipe inbound = 3; + repeated Pipe outbound = 4; +} + +message CompressorStation { + google.type.LatLng location = 1; + repeated Pipe inbound = 2; + repeated Pipe outbound = 3; +} + +message LngStorage { + string name = 1; + google.type.LatLng location = 2; + Pipe inbound = 3; + Pipe outbound = 4; +} diff --git a/gradle-plugin/src/test/resources/with-settings/src/functionalTest/proto/given/domain/oil_refinery.proto b/gradle-plugin/src/test/resources/with-settings/src/functionalTest/proto/given/domain/oil_refinery.proto new file mode 100644 index 0000000..c85fa31 --- /dev/null +++ b/gradle-plugin/src/test/resources/with-settings/src/functionalTest/proto/given/domain/oil_refinery.proto @@ -0,0 +1,56 @@ +/* +* Copyright 2024, TeamDev. All rights reserved. +* +* 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. +*/ +syntax = "proto3"; + +package given.domain; + +// +// This is a "vanilla" Protobuf file, which does not use Spine-specific features like +// custom options such as `type_url_prefix` or validation constraints. +// We also use "pure" Protobuf Java `protoc` plugin to process these files so that +// we recreate conditions we have before ProtoData gets into play after `protoc` +// finishes its work. +// + +option java_package = "io.spine.given.domain.oil"; +option java_outer_classname = "OilRefineryProto"; +option java_multiple_files = true; + +enum ProductType { + PT_UNKNOWN = 0; + PETROL = 1; + KEROSENE = 2; + DIESEL = 3; + FUEL_OIL = 4; + LUBRICATING_OIL = 5; + PARAFFIN_WAX = 6; + ASPHALT_BASE = 7; +} + +message Product { + ProductType type = 1; + float volume = 2; +} + +message Refinery { + string name = 1; + float input = 2; + repeated Product output = 3; +} diff --git a/pom.xml b/pom.xml index 698d7f4..4c81046 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 ProtoTap -0.8.2 +0.8.3 2015 diff --git a/version.gradle.kts b/version.gradle.kts index 4cefe43..c920366 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -24,4 +24,4 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -val versionToPublish: String by extra("0.8.2") +val versionToPublish: String by extra("0.8.3")