Skip to content

Commit 671ef8b

Browse files
deannagarciazhangskz
authored andcommitted
Refactor java maven GHA test to use our generated jars.
This allows us to test our maven setup without relying on static `pom.xml` files and clears the way to remove them in a subsequent CL. PiperOrigin-RevId: 658057911
1 parent 1869419 commit 671ef8b

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

.github/workflows/test_java.yml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
# # TODO: b/318555165 - enable the layering check. Currently it does
7070
# # not work correctly with the toolchain in this Docker image.
7171
# bazel: test --test_output=all //java:linkage_monitor --spawn_strategy=standalone --features=-layering_check
72-
72+
7373
protobuf-bom:
7474
name: Protobuf Maven BOM
7575
runs-on: ubuntu-latest
@@ -78,39 +78,19 @@ jobs:
7878
uses: protocolbuffers/protobuf-ci/checkout@v3
7979
with:
8080
ref: ${{ inputs.safe-checkout }}
81-
- name: Build protoc
82-
id: build-protoc
83-
uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v3
84-
with:
85-
image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d
86-
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
87-
architecture: linux-x86_64
88-
- name: Move protoc into place and clean up
89-
run: |
90-
mv ${{ steps.build-protoc.outputs.protoc }} protoc
91-
sudo rm -rf _build
92-
- name: Install snapshot version locally (not using generated pom.xml)
93-
run: |
94-
mvn -e -B -Dhttps.protocols=TLSv1.2 install -Dmaven.test.skip=true
95-
working-directory: java
96-
- name: Generate pom.xml files from the template
81+
- name: Generate maven artifacts with bazel and install using maven
9782
uses: protocolbuffers/protobuf-ci/bazel-docker@v3
9883
with:
9984
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-1fdbb997433cb22c1e49ef75ad374a8d6bb88702
10085
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
10186
bazel-cache: java_linux/11
102-
# protobuf-java and protobuf-java-util are the member of the BOM
10387
bash: |
104-
bazel build //java/core:core_mvn-pom //java/util:util_mvn-pom
105-
cp bazel-bin/java/core/core_mvn-pom.xml .
106-
cp bazel-bin/java/util/util_mvn-pom.xml .
107-
- name: Copy the generated pom.xml files to the local Maven repository
108-
shell: bash
109-
run: |
110-
LOCAL_MAVEN_GROUP_DIR="${HOME}/.m2/repository/com/google/protobuf"
111-
VERSION=$(grep "<version>" core_mvn-pom.xml | sed "s/<version>\(.*\)<\/version>/\1/" | xargs)
112-
cp core_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java/${VERSION}/protobuf-java-${VERSION}.pom
113-
cp util_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java-util/${VERSION}/protobuf-java-util-${VERSION}.pom
88+
bazel build //java:release
89+
mvn install:install-file -Dfile=bazel-bin/java/core/core_mvn-project.jar -DpomFile=bazel-bin/java/core/core_mvn-pom.xml
90+
mvn install:install-file -Dfile=bazel-bin/java/core/lite_mvn-project.jar -DpomFile=bazel-bin/java/core/lite_mvn-pom.xml
91+
mvn install:install-file -Dfile=bazel-bin/java/kotlin-lite/kotlin-lite_mvn-project.jar -DpomFile=bazel-bin/java/kotlin-lite/kotlin-lite_mvn-pom.xml
92+
mvn install:install-file -Dfile=bazel-bin/java/kotlin/kotlin_mvn-project.jar -DpomFile=bazel-bin/java/kotlin/kotlin_mvn-pom.xml
93+
mvn install:install-file -Dfile=bazel-bin/java/util/util_mvn-project.jar -DpomFile=bazel-bin/java/util/util_mvn-pom.xml
11494
- name: Clean up
11595
run: |
11696
sudo rm -rf _build

0 commit comments

Comments
 (0)