Skip to content

Commit ba58d68

Browse files
deannagarciacopybara-github
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: 656448482
1 parent 9bd8156 commit ba58d68

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

.github/workflows/test_java.yml

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,48 +79,28 @@ jobs:
7979
# # TODO: b/318555165 - enable the layering check. Currently it does
8080
# # not work correctly with the toolchain in this Docker image.
8181
# bazel: test --test_output=all //java:linkage_monitor --spawn_strategy=standalone --features=-layering_check
82-
83-
protobuf-bom:
84-
name: Protobuf Maven BOM
82+
83+
protobuf-maven:
84+
name: Test Maven
8585
runs-on: ubuntu-latest
8686
steps:
8787
- name: Checkout pending changes
8888
uses: protocolbuffers/protobuf-ci/checkout@v3
8989
with:
9090
ref: ${{ inputs.safe-checkout }}
91-
- name: Build protoc
92-
id: build-protoc
93-
uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v3
94-
with:
95-
image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d
96-
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
97-
architecture: linux-x86_64
98-
- name: Move protoc into place and clean up
99-
run: |
100-
mv ${{ steps.build-protoc.outputs.protoc }} protoc
101-
sudo rm -rf _build
102-
- name: Install snapshot version locally (not using generated pom.xml)
103-
run: |
104-
mvn -e -B -Dhttps.protocols=TLSv1.2 install -Dmaven.test.skip=true
105-
working-directory: java
106-
- name: Generate pom.xml files from the template
91+
- name: Generate maven artifacts with bazel and install using maven
10792
uses: protocolbuffers/protobuf-ci/bazel-docker@v3
10893
with:
10994
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-1fdbb997433cb22c1e49ef75ad374a8d6bb88702
11095
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
11196
bazel-cache: java_linux/11
112-
# protobuf-java and protobuf-java-util are the member of the BOM
11397
bash: |
114-
bazel build //java/core:core_mvn-pom //java/util:util_mvn-pom
115-
cp bazel-bin/java/core/core_mvn-pom.xml .
116-
cp bazel-bin/java/util/util_mvn-pom.xml .
117-
- name: Copy the generated pom.xml files to the local Maven repository
118-
shell: bash
119-
run: |
120-
LOCAL_MAVEN_GROUP_DIR="${HOME}/.m2/repository/com/google/protobuf"
121-
VERSION=$(grep "<version>" core_mvn-pom.xml | sed "s/<version>\(.*\)<\/version>/\1/" | xargs)
122-
cp core_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java/${VERSION}/protobuf-java-${VERSION}.pom
123-
cp util_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java-util/${VERSION}/protobuf-java-util-${VERSION}.pom
98+
bazel build //java:release
99+
mvn install:install-file -Dfile=bazel-bin/java/core/core_mvn-project.jar -DpomFile=bazel-bin/java/core/core_mvn-pom.xml
100+
mvn install:install-file -Dfile=bazel-bin/java/core/lite_mvn-project.jar -DpomFile=bazel-bin/java/core/lite_mvn-pom.xml
101+
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
102+
mvn install:install-file -Dfile=bazel-bin/java/kotlin/kotlin_mvn-project.jar -DpomFile=bazel-bin/java/kotlin/kotlin_mvn-pom.xml
103+
mvn install:install-file -Dfile=bazel-bin/java/util/util_mvn-project.jar -DpomFile=bazel-bin/java/util/util_mvn-pom.xml
124104
- name: Clean up
125105
run: |
126106
sudo rm -rf _build

0 commit comments

Comments
 (0)