Skip to content

Commit 269a060

Browse files
authored
build with workspaces (#54)
1 parent a8be16a commit 269a060

File tree

20 files changed

+387
-7
lines changed

20 files changed

+387
-7
lines changed

src/main/kotlin/com/parmet/buf/gradle/BufPlugin.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ class BufPlugin : Plugin<Project> {
2828
project.configurations.create(BUF_CONFIGURATION_NAME)
2929

3030
if (project.hasProtobufGradlePlugin()) {
31-
project.failForWorkspacesAndPlugin()
31+
project.failForWorkspaceAndPlugin()
3232
project.afterEvaluate { configureBufWithProtobufGradle(ext) }
3333
} else {
34-
project.withProtobufGradlePlugin { project.failForWorkspacesAndPlugin() }
34+
project.withProtobufGradlePlugin { project.failForWorkspaceAndPlugin() }
3535
project.configureBuf(ext)
3636
}
3737
}
3838

39-
private fun Project.failForWorkspacesAndPlugin() {
40-
check(!project.usesWorkspaces(), ::WORKSPACES_AND_PROTOBUF_PLUGIN_FAILURE_MESSAGE)
39+
private fun Project.failForWorkspaceAndPlugin() {
40+
check(!project.usesWorkspaces(), ::WORKSPACE_AND_PROTOBUF_PLUGIN_FAILURE_MESSAGE)
4141
}
4242

4343
private fun Project.configureBufWithProtobufGradle(ext: BufExtension) {
@@ -64,9 +64,9 @@ class BufPlugin : Plugin<Project> {
6464
}
6565
}
6666

67-
private val WORKSPACES_AND_PROTOBUF_PLUGIN_FAILURE_MESSAGE =
67+
private val WORKSPACE_AND_PROTOBUF_PLUGIN_FAILURE_MESSAGE =
6868
"""
69-
A project cannot use both the protobuf-gradle-plugin and Buf workspaces.
69+
A project cannot use both the protobuf-gradle-plugin and a Buf workspace.
7070
If you have multiple protobuf source directories and you would like to
7171
use the protobuf-gradle-plugin, configure the protobuf-gradle-plugin to use
7272
those directories as source directories in the appropriate source set. If you
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2022 Andrew Parmet
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
package com.parmet.buf.gradle
17+
18+
class BuildWithWorkspaceTest : AbstractBuildTest()

src/test/kotlin/com/parmet/buf/gradle/ConfigOverrideableLintTests.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (c) 2022 Andrew Parmet
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
116
package com.parmet.buf.gradle
217

318
import com.google.common.truth.Truth.assertThat

src/test/kotlin/com/parmet/buf/gradle/ConfigurationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ class ConfigurationTest : AbstractBufIntegrationTest() {
1616

1717
private fun assertFailure() {
1818
val result = gradleRunner().withArguments(":tasks").buildAndFail()
19-
assertThat(result.output).contains("cannot use both the protobuf-gradle-plugin and Buf workspaces")
19+
assertThat(result.output).contains("cannot use both the protobuf-gradle-plugin and a Buf workspace")
2020
}
2121
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2022 Andrew Parmet
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
version: v1
15+
directories:
16+
- workspace
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2022 Andrew Parmet
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
plugins {
17+
id 'java'
18+
id 'com.parmet.buf'
19+
id 'maven-publish'
20+
}
21+
22+
buf {
23+
publishSchema = true
24+
imageArtifact {
25+
groupId = 'foo'
26+
artifactId = 'bar'
27+
version = '2319'
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2022 Andrew Parmet
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
syntax = "proto3";
15+
16+
package parmet.buf.test.v1;
17+
18+
message BasicMessage {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2022 Andrew Parmet
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
version: v1
15+
directories:
16+
- workspace
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2022 Andrew Parmet
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
plugins {
17+
id 'java'
18+
id 'com.parmet.buf'
19+
id 'maven-publish'
20+
}
21+
22+
buf {
23+
publishSchema = true
24+
}
25+
26+
publishing {
27+
publications {
28+
maven(MavenPublication) {
29+
groupId = 'foo'
30+
artifactId = 'bar'
31+
version = '2319'
32+
from components.java
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)