diff --git a/src/test/kotlin/build/buf/gradle/ConfigurationTest.kt b/src/test/kotlin/build/buf/gradle/ConfigurationTest.kt index 82ac6874..1dce4a49 100644 --- a/src/test/kotlin/build/buf/gradle/ConfigurationTest.kt +++ b/src/test/kotlin/build/buf/gradle/ConfigurationTest.kt @@ -28,8 +28,23 @@ class ConfigurationTest : AbstractBufIntegrationTest() { assertFailure() } + @Test + fun `project can use both buf-yaml and the protobuf-gradle-plugin, protobuf applied first`() { + assertSuccess() + } + + @Test + fun `project can use both buf-yaml and the protobuf-gradle-plugin, protobuf applied second`() { + assertSuccess() + } + private fun assertFailure() { val result = gradleRunner().withArguments(":tasks").buildAndFail() assertThat(result.output).contains("cannot use both the protobuf-gradle-plugin and a Buf workspace") } + + private fun assertSuccess() { + val result = gradleRunner().withArguments(":tasks").build() + assertThat(result.output).doesNotContain("cannot use both the protobuf-gradle-plugin and a Buf workspace") + } } diff --git a/src/test/kotlin/build/buf/gradle/PublishWithWorkspaceTest.kt b/src/test/kotlin/build/buf/gradle/PublishWithWorkspaceTest.kt index 4644ece6..b86ad28a 100644 --- a/src/test/kotlin/build/buf/gradle/PublishWithWorkspaceTest.kt +++ b/src/test/kotlin/build/buf/gradle/PublishWithWorkspaceTest.kt @@ -14,4 +14,16 @@ package build.buf.gradle -class PublishWithWorkspaceTest : AbstractPublishTest() +import org.junit.jupiter.api.Test + +class PublishWithWorkspaceTest : AbstractPublishTest() { + @Test + fun `publish schema with explicit artifact details v2`() { + super.`publish schema with explicit artifact details`() + } + + @Test + fun `publish schema with inferred artifact details v2`() { + super.`publish schema with inferred artifact details`() + } +} diff --git a/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_first/buf.yaml b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_first/buf.yaml new file mode 100644 index 00000000..45ee9f96 --- /dev/null +++ b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_first/buf.yaml @@ -0,0 +1,3 @@ +version: v2 +modules: + - path: workspace diff --git a/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_first/build.gradle b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_first/build.gradle new file mode 100644 index 00000000..5b4ed954 --- /dev/null +++ b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_first/build.gradle @@ -0,0 +1,9 @@ +plugins { + id 'java' + id 'com.google.protobuf' version "$protobufGradleVersion" + id 'build.buf' +} + +repositories { + mavenCentral() +} diff --git a/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_second/buf.yaml b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_second/buf.yaml new file mode 100644 index 00000000..45ee9f96 --- /dev/null +++ b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_second/buf.yaml @@ -0,0 +1,3 @@ +version: v2 +modules: + - path: workspace diff --git a/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_second/build.gradle b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_second/build.gradle new file mode 100644 index 00000000..e58c8a40 --- /dev/null +++ b/src/test/resources/ConfigurationTest/project_can_use_both_buf_yaml_and_the_protobuf_gradle_plugin_protobuf_applied_second/build.gradle @@ -0,0 +1,9 @@ +plugins { + id 'java' + id 'build.buf' + id 'com.google.protobuf' version "$protobufGradleVersion" +} + +repositories { + mavenCentral() +} diff --git a/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/buf.yaml b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/buf.yaml new file mode 100644 index 00000000..45ee9f96 --- /dev/null +++ b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/buf.yaml @@ -0,0 +1,3 @@ +version: v2 +modules: + - path: workspace diff --git a/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/build.gradle b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/build.gradle new file mode 100644 index 00000000..6b937d2a --- /dev/null +++ b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/build.gradle @@ -0,0 +1,24 @@ +plugins { + id 'java' + id 'build.buf' + id 'maven-publish' +} + +repositories { + mavenCentral() +} + +buf { + publishSchema = true + imageArtifact { + groupId = 'foo' + artifactId = 'bar' + version = '2319' + } +} + +publishing { + repositories { + maven { url 'build/repos/test' } + } +} diff --git a/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/workspace/test.proto b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/workspace/test.proto new file mode 100644 index 00000000..7e932c42 --- /dev/null +++ b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_explicit_artifact_details_v2/workspace/test.proto @@ -0,0 +1,19 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// 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 buf.test.v1; + +message BasicMessage {} diff --git a/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/buf.yaml b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/buf.yaml new file mode 100644 index 00000000..45ee9f96 --- /dev/null +++ b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/buf.yaml @@ -0,0 +1,3 @@ +version: v2 +modules: + - path: workspace diff --git a/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/build.gradle b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/build.gradle new file mode 100644 index 00000000..ef2621ef --- /dev/null +++ b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/build.gradle @@ -0,0 +1,28 @@ +plugins { + id 'java' + id 'build.buf' + id 'maven-publish' +} + +repositories { + mavenCentral() +} + +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/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/workspace/test.proto b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/workspace/test.proto new file mode 100644 index 00000000..7e932c42 --- /dev/null +++ b/src/test/resources/PublishWithWorkspaceTest/publish_schema_with_inferred_artifact_details_v2/workspace/test.proto @@ -0,0 +1,19 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// 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 buf.test.v1; + +message BasicMessage {}