Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any plugin order #5

Merged
merged 15 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions buildSrc/src/main/kotlin/module.gradle.kts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -165,5 +163,3 @@ fun Module.configureGitHubPages() {
rootFolder.set(rootDir)
}
}


12 changes: 6 additions & 6 deletions dependencies.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 **Thu May 02 22:54:03 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.
Expand Down Expand Up @@ -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 **Thu May 02 22:54:03 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.
Expand Down Expand Up @@ -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).
This report was generated on **Thu May 02 22:54:03 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).
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
23 changes: 8 additions & 15 deletions gradle-plugin/src/test/resources/with-settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -87,3 +72,11 @@ 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)
}

alexander-yevsyukov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
-->
<groupId>io.spine.tools</groupId>
<artifactId>ProtoTap</artifactId>
<version>0.8.2</version>
<version>0.8.3</version>

<inceptionYear>2015</inceptionYear>

Expand Down
2 changes: 1 addition & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Loading