From 95262d728a9e1936049a19455b3e0c905b103146 Mon Sep 17 00:00:00 2001 From: Ian Duffy Date: Mon, 12 Oct 2026 20:56:48 +0100 Subject: [PATCH] ci: build the Java release pom in CI, and fix its jar execution The Java build copies bindings/java/release/pom.xml over the generated pom, but CI built the generated pom. Dependabot updates to the release pom were merged without a build, and a maven-jar-plugin 3.x update would break the deploy build. Make bindings/java/test.sh build the release pom with the package version, and run the package phase that deploy.sh uses. Move the copy into write_release_pom in scripts/common.sh, so the build and the tests use the same pom. Remove the duplicate jar goal from the jar execution. Maven already builds the main jar, and maven-jar-plugin 3.x rejects the second one. Co-Authored-By: Claude Opus 5.5 --- bindings/java/build.sh | 4 +--- bindings/java/release/pom.xml | 1 - bindings/java/test.sh | 9 ++++++++- scripts/common.sh | 8 ++++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bindings/java/build.sh b/bindings/java/build.sh index 6570b3738..5cad84ea0 100755 --- a/bindings/java/build.sh +++ b/bindings/java/build.sh @@ -57,6 +57,4 @@ docker container run --rm --user "${codegen_run_user:?}" -v $self_dir:/local "${ bash $root_dir/scripts/fix-java-duplicate-imports.sh # Dependabot updates release/pom.xml. Replace the generated pom with it. -awk -v version="$package_version" \ - '!done && sub(/[^<]*<\/version>/, "" version "") { done = 1 } 1' \ - "$self_dir/release/pom.xml" > "$src_dir/pom.xml" +write_release_pom "$src_dir/pom.xml" diff --git a/bindings/java/release/pom.xml b/bindings/java/release/pom.xml index a146737a3..553dcd628 100644 --- a/bindings/java/release/pom.xml +++ b/bindings/java/release/pom.xml @@ -93,7 +93,6 @@ - jar test-jar diff --git a/bindings/java/test.sh b/bindings/java/test.sh index e1583601b..d2f53c562 100755 --- a/bindings/java/test.sh +++ b/bindings/java/test.sh @@ -9,4 +9,11 @@ root_dir=$(readlink -f "$self_dir/../..") src_dir="$self_dir/src" cd $src_dir -mvn test + +# Build with release/pom.xml, because the next generation ships it. Run the +# package phase too, which builds the jars that deploy.sh uploads. +release_pom=".release-pom.xml" +write_release_pom "$src_dir/$release_pom" +trap 'rm -f "$src_dir/$release_pom"' EXIT +mvn -f "$release_pom" test +mvn -f "$release_pom" -DskipTests package diff --git a/scripts/common.sh b/scripts/common.sh index 6d49fbe6f..dc0b82b65 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -55,6 +55,14 @@ function cloudsmith_version_published { [ "${count:-0}" -gt 0 ] } +# Dependabot updates bindings/java/release/pom.xml. Write it with the package +# version, as the pom that the Java binding ships. +function write_release_pom { + awk -v version="$package_version" \ + '!done && sub(/[^<]*<\/version>/, "" version "") { done = 1 } 1' \ + "$root_dir/bindings/java/release/pom.xml" > "$1" +} + function die { echo "$@" exit 1