Skip to content

Commit

Permalink
Add test for running via classpath dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yevsyukov committed Apr 30, 2024
1 parent 91a3550 commit 3f603c0
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ internal class PluginSpec {
assertDescriptorSetFileExits()
}

@Test
fun `work as a 'classpath' dependency of 'buildscript'`() {
createProject("via-classpath")
runBuild()
assertJavaCodeGenerated()
assertRequestFileExits()
}

private fun assertJavaCodeGenerated() {
val javaDir = resultDir.resolve("java")
javaDir.countFiles() shouldNotBe 0
Expand Down
62 changes: 62 additions & 0 deletions gradle-plugin/src/test/resources/via-classpath/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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()
dependencies {
classpath("io.spine.tools:prototap-gradle-plugin:@PROTOTAP_VERSION@")
}
}

plugins {
java
`java-test-fixtures`
id("com.google.protobuf")
}

apply(plugin = "@PROTOTAP_PLUGIN_ID@")

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)
}
31 changes: 31 additions & 0 deletions gradle-plugin/src/test/resources/via-classpath/settings.gradle.kts
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()
}
}
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;
}

0 comments on commit 3f603c0

Please sign in to comment.