From 9ef41014fd4eee198b0a795ef3596f991c11edd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menneken?= Date: Thu, 9 Oct 2025 09:25:28 +0200 Subject: [PATCH] exclude pre-packaged proto files from the build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes #145. The Authzed API uses a couple of third-party proto definitions. After change #141 all of those third-party proto files were copied into the source folder and compiled as Java classes into the final JAR. This led to duplicated classes being on the classpath, e.g. com.google.rpc.Status which was now packed inside `com.authzed.api:authzed` and `com.google.api.grpc:proto-google-common-protos`. This makes dependency management very hard. Fortunately, most of the third-party protos come pre-compiled and pre-packaged with their own JAR files, available on Maven Central. They can simply be pulled in as compile-time dependency. The only exception is the grpc-gateway, where we have to copy the protos similar to the original approach. Signed-off-by: André Menneken --- build.gradle | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 610249d9..5c78f44e 100644 --- a/build.gradle +++ b/build.gradle @@ -106,10 +106,23 @@ dependencies { implementation "io.grpc:grpc-stub:${grpcVersion}" runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}" compileOnly "org.apache.tomcat:annotations-api:6.0.53" + + implementation "com.google.api.grpc:proto-google-common-protos:2.61.3" + implementation("build.buf:protovalidate:1.0.0") + // In the future this can probably be removed in favor of "protovalidate" + // See https://buf.build/blog/protoc-gen-validate-v1-and-v2 + implementation("build.buf.protoc-gen-validate:pgv-java-stub:1.2.1") +} + +// There is no pre-packaged JAR available that contains the gRPC Gateway proto files +task gatewayProtos(type: Exec) { + mkdir bufDir + commandLine("buf", "export", "--exclude-imports", "buf.build/grpc-ecosystem/grpc-gateway", "-o", bufDir) } task authzedProtos(type: Exec) { - commandLine("buf", "export", "buf.build/authzed/api:${authzedProtoCommit}", "-o", bufDir) + dependsOn gatewayProtos + commandLine("buf", "export", "--exclude-imports", "buf.build/authzed/api:${authzedProtoCommit}", "-o", bufDir) } protobuf {