diff --git a/src/test/kotlin/com/parmet/buf/gradle/AbstractPublishTest.kt b/src/test/kotlin/com/parmet/buf/gradle/AbstractPublishTest.kt new file mode 100644 index 00000000..d22cb079 --- /dev/null +++ b/src/test/kotlin/com/parmet/buf/gradle/AbstractPublishTest.kt @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Andrew Parmet + * + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.parmet.buf.gradle + +import com.google.common.truth.Truth.assertThat +import org.gradle.testkit.runner.TaskOutcome.SUCCESS +import org.junit.jupiter.api.Test +import java.nio.file.Paths + +abstract class AbstractPublishTest : AbstractBufIntegrationTest() { + @Test + fun `publish schema with explicit artifact details`() { + assertImagePublication("bar") + } + + @Test + fun `publish schema with inferred artifact details`() { + assertImagePublication("bar-bufbuild") + } + + private fun assertImagePublication(artifactId: String) { + assertThat(publishRunner().build().task(":publish")?.outcome).isEqualTo(SUCCESS) + + val builtImage = Paths.get(projectDir.path, "build", "bufbuild", "image.json") + val publishedImage = Paths.get(projectDir.path, "build", "repos", "test", "foo", artifactId, "2319", "$artifactId-2319.json") + + assertThat(publishedImage.toFile().readText()).isEqualTo(builtImage.toFile().readText()) + assertThat(publishedImage.toFile().readText()).contains("BasicMessage") + } +} diff --git a/src/test/kotlin/com/parmet/buf/gradle/PublishTest.kt b/src/test/kotlin/com/parmet/buf/gradle/PublishTest.kt index 37151c7a..6d837ad5 100644 --- a/src/test/kotlin/com/parmet/buf/gradle/PublishTest.kt +++ b/src/test/kotlin/com/parmet/buf/gradle/PublishTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Andrew Parmet + * Copyright (c) 2022 Andrew Parmet * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,28 +15,4 @@ package com.parmet.buf.gradle -import com.google.common.truth.Truth.assertThat -import org.gradle.testkit.runner.TaskOutcome.SUCCESS -import org.junit.jupiter.api.Test -import java.nio.file.Paths - -class PublishTest : AbstractBufIntegrationTest() { - @Test - fun `publish schema with explicit artifact details`() { - assertImagePublication("bar") - } - - @Test - fun `publish schema with inferred artifact details`() { - assertImagePublication("bar-bufbuild") - } - - private fun assertImagePublication(artifactId: String) { - assertThat(publishRunner().build().task(":publish")?.outcome).isEqualTo(SUCCESS) - - val builtImage = Paths.get(projectDir.path, "build", "bufbuild", "image.json") - val publishedImage = Paths.get(projectDir.path, "build", "repos", "test", "foo", artifactId, "2319", "$artifactId-2319.json") - - assertThat(publishedImage.toFile().readText()).isEqualTo(builtImage.toFile().readText()) - } -} +class PublishTest : AbstractPublishTest() diff --git a/src/test/kotlin/com/parmet/buf/gradle/PublishWithProtobufGradleTest.kt b/src/test/kotlin/com/parmet/buf/gradle/PublishWithProtobufGradleTest.kt new file mode 100644 index 00000000..09ecb890 --- /dev/null +++ b/src/test/kotlin/com/parmet/buf/gradle/PublishWithProtobufGradleTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022 Andrew Parmet + * + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.parmet.buf.gradle + +class PublishWithProtobufGradleTest : AbstractPublishTest() diff --git a/src/test/resources/PublishTest/publish schema with explicit artifact details/build.gradle b/src/test/resources/PublishTest/publish schema with explicit artifact details/build.gradle index e0d0ce03..c12a88be 100644 --- a/src/test/resources/PublishTest/publish schema with explicit artifact details/build.gradle +++ b/src/test/resources/PublishTest/publish schema with explicit artifact details/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Andrew Parmet + * Copyright (c) 2022 Andrew Parmet * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,21 +15,10 @@ plugins { id 'java' - id 'com.google.protobuf' version "$protobufGradleVersion" id 'com.parmet.buf' id 'maven-publish' } -repositories { mavenCentral() } - -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:$protobufVersion" - } -} - -compileJava.enabled = false - buf { publishSchema = true imageArtifact { diff --git a/src/test/resources/PublishTest/publish schema with explicit artifact details/test.proto b/src/test/resources/PublishTest/publish schema with explicit artifact details/test.proto new file mode 100644 index 00000000..13f19139 --- /dev/null +++ b/src/test/resources/PublishTest/publish schema with explicit artifact details/test.proto @@ -0,0 +1,18 @@ +// Copyright (c) 2022 Andrew Parmet +// +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package parmet.buf.test.v1; + +message BasicMessage {} diff --git a/src/test/resources/PublishTest/publish schema with inferred artifact details/build.gradle b/src/test/resources/PublishTest/publish schema with inferred artifact details/build.gradle index 44abbb08..550a494d 100644 --- a/src/test/resources/PublishTest/publish schema with inferred artifact details/build.gradle +++ b/src/test/resources/PublishTest/publish schema with inferred artifact details/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Andrew Parmet + * Copyright (c) 2022 Andrew Parmet * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,21 +15,10 @@ plugins { id 'java' - id 'com.google.protobuf' version "$protobufGradleVersion" id 'com.parmet.buf' id 'maven-publish' } -repositories { mavenCentral() } - -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:$protobufVersion" - } -} - -compileJava.enabled = false - buf { publishSchema = true } diff --git a/src/test/resources/PublishTest/publish schema with inferred artifact details/test.proto b/src/test/resources/PublishTest/publish schema with inferred artifact details/test.proto new file mode 100644 index 00000000..13f19139 --- /dev/null +++ b/src/test/resources/PublishTest/publish schema with inferred artifact details/test.proto @@ -0,0 +1,18 @@ +// Copyright (c) 2022 Andrew Parmet +// +// 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 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package parmet.buf.test.v1; + +message BasicMessage {} diff --git a/src/test/resources/PublishWithProtobufGradleTest/publish schema with explicit artifact details/build.gradle b/src/test/resources/PublishWithProtobufGradleTest/publish schema with explicit artifact details/build.gradle new file mode 100644 index 00000000..e0d0ce03 --- /dev/null +++ b/src/test/resources/PublishWithProtobufGradleTest/publish schema with explicit artifact details/build.gradle @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Andrew Parmet + * + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id 'java' + id 'com.google.protobuf' version "$protobufGradleVersion" + id 'com.parmet.buf' + id 'maven-publish' +} + +repositories { mavenCentral() } + +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:$protobufVersion" + } +} + +compileJava.enabled = false + +buf { + publishSchema = true + imageArtifact { + groupId = 'foo' + artifactId = 'bar' + version = '2319' + } +} + +publishing { + repositories { + maven { url 'build/repos/test' } + } +} diff --git a/src/test/resources/PublishTest/publish schema with explicit artifact details/src/main/proto/parmet/buf/test/v1/test.proto b/src/test/resources/PublishWithProtobufGradleTest/publish schema with explicit artifact details/src/main/proto/parmet/buf/test/v1/test.proto similarity index 100% rename from src/test/resources/PublishTest/publish schema with explicit artifact details/src/main/proto/parmet/buf/test/v1/test.proto rename to src/test/resources/PublishWithProtobufGradleTest/publish schema with explicit artifact details/src/main/proto/parmet/buf/test/v1/test.proto diff --git a/src/test/resources/PublishWithProtobufGradleTest/publish schema with inferred artifact details/build.gradle b/src/test/resources/PublishWithProtobufGradleTest/publish schema with inferred artifact details/build.gradle new file mode 100644 index 00000000..44abbb08 --- /dev/null +++ b/src/test/resources/PublishWithProtobufGradleTest/publish schema with inferred artifact details/build.gradle @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Andrew Parmet + * + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id 'java' + id 'com.google.protobuf' version "$protobufGradleVersion" + id 'com.parmet.buf' + id 'maven-publish' +} + +repositories { mavenCentral() } + +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:$protobufVersion" + } +} + +compileJava.enabled = false + +buf { + publishSchema = true +} + +publishing { + repositories { + maven { url 'build/repos/test' } + } + + publications { + maven(MavenPublication) { + groupId = 'foo' + artifactId = 'bar' + version = '2319' + from components.java + } + } +} diff --git a/src/test/resources/PublishTest/publish schema with inferred artifact details/src/main/proto/parmet/buf/test/v1/test.proto b/src/test/resources/PublishWithProtobufGradleTest/publish schema with inferred artifact details/src/main/proto/parmet/buf/test/v1/test.proto similarity index 100% rename from src/test/resources/PublishTest/publish schema with inferred artifact details/src/main/proto/parmet/buf/test/v1/test.proto rename to src/test/resources/PublishWithProtobufGradleTest/publish schema with inferred artifact details/src/main/proto/parmet/buf/test/v1/test.proto