From b13a7d80cf43c20fb617e59d48aa784eb790053b Mon Sep 17 00:00:00 2001 From: Laurent Goujon Date: Thu, 28 Mar 2024 06:06:21 -0700 Subject: [PATCH] GH-40843: [Java] Cleanup protobuf-maven-plugin usage (#40844) ### Rationale for this change `protobuf-maven-plugin` usage in Arrow codebase does not follow plugins best practices like sharing the same output directory for different execution or not using test goals for generating test classes ### What changes are included in this PR? * Add protobuf-maven-plugin plugin to top level pom.xml under pluginManagement to define version and common configuration for all modules * Remove unnecessary executions of test-compile goal when no test protobufs are present * Remove use of outputDirectory and clearOutputDirectory and let the plugin choose it for each execution (the default output directory is based on the phase (main vs test) and the language/plugin-id) * Replace use of compile/compile-custom goals with test-compile/test-compile-custom when generating test protobufs ### Are these changes tested? As those changes are in the build system, they are covered by the build framework and tests run as part of the build ### Are there any user-facing changes? None * GitHub Issue: #40843 Authored-by: Laurent Goujon Signed-off-by: David Li --- java/dataset/pom.xml | 11 ++++------ java/flight/flight-core/pom.xml | 16 ++------------- .../src/test/{protobuf => proto}/perf.proto | 0 .../src/test/{protobuf => proto}/test.proto | 0 java/flight/pom.xml | 20 ------------------- java/gandiva/pom.xml | 11 ++++------ java/pom.xml | 10 ++++++++++ 7 files changed, 20 insertions(+), 48 deletions(-) rename java/flight/flight-core/src/test/{protobuf => proto}/perf.proto (100%) rename java/flight/flight-core/src/test/{protobuf => proto}/test.proto (100%) diff --git a/java/dataset/pom.xml b/java/dataset/pom.xml index a003fd18068ec..43b913167390f 100644 --- a/java/dataset/pom.xml +++ b/java/dataset/pom.xml @@ -177,18 +177,15 @@ org.xolstice.maven.plugins protobuf-maven-plugin - 0.6.1 - - com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} - - ../../cpp/src/jni/dataset/proto - + src compile - test-compile + + ../../cpp/src/jni/dataset/proto + diff --git a/java/flight/flight-core/pom.xml b/java/flight/flight-core/pom.xml index 98491e7ba091e..830caf8a28246 100644 --- a/java/flight/flight-core/pom.xml +++ b/java/flight/flight-core/pom.xml @@ -228,19 +228,11 @@ org.xolstice.maven.plugins protobuf-maven-plugin - 0.6.1 - - com.google.protobuf:protoc:${dep.protobuf-bom.version}:exe:${os.detected.classifier} - false - grpc-java - io.grpc:protoc-gen-grpc-java:${dep.grpc-bom.version}:exe:${os.detected.classifier} - src ${basedir}/../../../format/ - ${project.build.directory}/generated-sources/protobuf compile @@ -249,13 +241,9 @@ test - - ${basedir}/src/test/protobuf - ${project.build.directory}/generated-test-sources//protobuf - - compile - compile-custom + test-compile + test-compile-custom diff --git a/java/flight/flight-core/src/test/protobuf/perf.proto b/java/flight/flight-core/src/test/proto/perf.proto similarity index 100% rename from java/flight/flight-core/src/test/protobuf/perf.proto rename to java/flight/flight-core/src/test/proto/perf.proto diff --git a/java/flight/flight-core/src/test/protobuf/test.proto b/java/flight/flight-core/src/test/proto/test.proto similarity index 100% rename from java/flight/flight-core/src/test/protobuf/test.proto rename to java/flight/flight-core/src/test/proto/test.proto diff --git a/java/flight/pom.xml b/java/flight/pom.xml index 2f777ab42b756..5b9caafa82ef9 100644 --- a/java/flight/pom.xml +++ b/java/flight/pom.xml @@ -32,26 +32,6 @@ flight-integration-tests - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.6.1 - - - com.google.protobuf:protoc:${dep.protobuf-bom.version}:exe:${os.detected.classifier} - - grpc-java - io.grpc:protoc-gen-grpc-java:${dep.grpc-bom.version}:exe:${os.detected.classifier} - - - - - - - pin-mockito-jdk8 diff --git a/java/gandiva/pom.xml b/java/gandiva/pom.xml index 819baee11edec..0d2a23345f6ea 100644 --- a/java/gandiva/pom.xml +++ b/java/gandiva/pom.xml @@ -132,18 +132,15 @@ org.xolstice.maven.plugins protobuf-maven-plugin - 0.6.1 - - com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} - - proto - + src compile - test-compile + + proto + diff --git a/java/pom.xml b/java/pom.xml index add2823ccb0d2..659ccfca08c76 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -637,6 +637,16 @@ + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + com.google.protobuf:protoc:${dep.protobuf-bom.version}:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${dep.grpc-bom.version}:exe:${os.detected.classifier} + +