Skip to content

Commit b736f77

Browse files
authored
Bump protobuf to v4 (#588)
CEL conformance tests still have to use protobuf 3, because grpc-java doesn't work with protobuf 4 yet. To allow that, a new artifact `cel-generated-pb3` has been added.
1 parent d561300 commit b736f77

File tree

6 files changed

+69
-4
lines changed

6 files changed

+69
-4
lines changed

bom/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626
api(project(":cel-core"))
2727
api(project(":cel-generated-antlr", "shadow"))
2828
api(project(":cel-generated-pb"))
29+
api(project(":cel-generated-pb3"))
2930
api(project(":cel-conformance"))
3031
api(project(":cel-jackson"))
3132
api(project(":cel-tools"))

conformance/build.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ sourceSets.main {
3333
java.srcDir(layout.buildDirectory.dir("generated/source/proto/main/grpc"))
3434
}
3535

36+
configurations.all { exclude(group = "org.projectnessie.cel", module = "cel-generated-pb") }
37+
3638
dependencies {
3739
implementation(project(":cel-core"))
3840
implementation(testFixtures(project(":cel-core")))
39-
implementation(testFixtures(project(":cel-generated-pb")))
41+
implementation(testFixtures(project(":cel-generated-pb3")))
4042

41-
implementation(libs.protobuf.java)
43+
implementation(libs.protobuf.java) { version { strictly(libs.versions.protobuf3.get()) } }
4244

4345
implementation(libs.grpc.protobuf)
4446
implementation(libs.grpc.stub)
@@ -59,7 +61,7 @@ configure<ProtobufExtension> {
5961
// Configure the protoc executable
6062
protoc {
6163
// Download from repositories
62-
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
64+
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf3.get()}"
6365
}
6466
plugins {
6567
this.create("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:${libs.versions.grpc.get()}" }

generated-pb3/build.gradle.kts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (C) 2021 The Authors of CEL-Java
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+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.google.protobuf.gradle.ProtobufExtension
18+
import com.google.protobuf.gradle.ProtobufPlugin
19+
20+
plugins {
21+
`java-library`
22+
`maven-publish`
23+
signing
24+
`cel-conventions`
25+
`java-test-fixtures`
26+
}
27+
28+
apply<ProtobufPlugin>()
29+
30+
sourceSets.main {
31+
java.srcDir(layout.buildDirectory.dir("generated/source/proto/main/java"))
32+
java.destinationDirectory.set(layout.buildDirectory.dir("classes/java/generated"))
33+
}
34+
35+
sourceSets.test {
36+
java.srcDir(layout.buildDirectory.dir("generated/source/proto/test/java"))
37+
java.destinationDirectory.set(layout.buildDirectory.dir("classes/java/generatedTest"))
38+
}
39+
40+
dependencies {
41+
api(libs.protobuf.java) { version { strictly(libs.versions.protobuf3.get()) } }
42+
43+
// Since we need the protobuf stuff in this cel-core module, it's easy to generate the
44+
// gRPC code as well. But do not expose the gRPC dependencies "publicly".
45+
compileOnly(libs.grpc.protobuf)
46+
compileOnly(libs.grpc.stub)
47+
compileOnly(libs.tomcat.annotations.api)
48+
}
49+
50+
// *.proto files taken from https://github.com/googleapis/googleapis/ repo, available as a git
51+
// submodule
52+
configure<ProtobufExtension> {
53+
// Configure the protoc executable
54+
protoc {
55+
// Download from repositories
56+
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf3.get()}"
57+
}
58+
}

generated-pb3/src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../generated-pb/src

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jmh = "1.37"
1414
junit = "5.10.3"
1515
nessieBuildPlugins = "0.2.24"
1616
nessieRunPlugin = "0.27.3"
17-
protobuf = "3.25.4"
17+
protobuf = "4.27.3"
18+
protobuf3 = "3.25.4"
1819
protobufPlugin = "0.9.4"
1920
shadowPlugin = "8.1.1"
2021
slf4j = "1.7.36"

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ celProject("generated-antlr")
9191

9292
celProject("generated-pb")
9393

94+
celProject("generated-pb3")
95+
9496
celProject("core")
9597

9698
celProject("jackson")

0 commit comments

Comments
 (0)