Skip to content

Commit 0051f49

Browse files
authored
feat: Use gapic-generator-java jar in the client library generation process (#918)
1 parent 29273a6 commit 0051f49

File tree

11 files changed

+104
-555
lines changed

11 files changed

+104
-555
lines changed

.githooks/pre-commit

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ fi
105105
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ]
106106
then
107107
echo_status "Running Java linter..."
108-
bazel --batch run --disk_cache="$BAZEL_CACHE_DIR" //:google_java_format_verification
108+
mvn fmt:check
109109
FORMAT_STATUS=$?
110110
if [ $FORMAT_STATUS != 0 ]
111111
then
112-
echo_error "Linting failed." "Please run :google_java_format and try again."
112+
echo_error "Linting failed." "Please run mvn fmt:format and try again."
113113
exit 1
114114
fi
115115
fi
@@ -118,7 +118,7 @@ fi
118118
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ]
119119
then
120120
echo_status "Checking unit tests..."
121-
bazel --batch test //:units --disk_cache="$BAZEL_CACHE_DIR"
121+
mvn test
122122
TEST_STATUS=$?
123123
if [ $TEST_STATUS != 0 ]
124124
then

.github/workflows/ci-maven.yaml

+52-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: ci-maven
77
env:
88
SHOWCASE_VERSION: 0.25.0
99
jobs:
10-
units:
10+
build:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
@@ -22,11 +22,34 @@ jobs:
2222
- run: java -version
2323
- name: Unit Tests
2424
run: |
25-
mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \
25+
mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \
2626
-Dfmt.skip
27+
- run: bazelisk version
28+
- name: Integration Tests
29+
run: |
30+
bazel --batch test //test/integration/...
31+
- name: Gradle Build Generated Storage Client Library
32+
run: |
33+
echo "Building Storage lib from generated source..."
34+
mkdir /tmp/java-storage
35+
bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java
36+
tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage
37+
pushd /tmp/java-storage/google-cloud-storage-v2-java
38+
./gradlew clean build publishToMavenLocal sourcesJar allJars
39+
popd
2740
28-
units-java8:
29-
name: "units (8) except gapic-generator-java"
41+
- name: Gradle Build Generated Compute Client Library
42+
run: |
43+
echo "Building Compute lib from generated source..."
44+
mkdir /tmp/java-compute
45+
bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java
46+
tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute
47+
pushd /tmp/java-compute/google-cloud-compute-small-v1-java
48+
./gradlew clean build publishToMavenLocal sourcesJar allJars
49+
popd
50+
51+
build-java8-except-gapic-generator-java:
52+
name: "build(8) except for gapic-generator-java"
3053
runs-on: ubuntu-latest
3154
steps:
3255
- uses: actions/checkout@v3
@@ -65,8 +88,8 @@ jobs:
6588
-Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \
6689
-Dfmt.skip
6790
68-
units-java8-gapic-generator-java:
69-
name: "units (8) for gapic-generator-java"
91+
build-java8-gapic-generator-java:
92+
name: "build(8) for gapic-generator-java"
7093
runs-on: ubuntu-latest
7194
steps:
7295
- uses: actions/checkout@v3
@@ -89,6 +112,29 @@ jobs:
89112
shell: bash
90113
run: |
91114
mvn -V -B -ntp surefire:test --projects 'gapic-generator-java'
115+
- run: bazelisk version
116+
- name: Integration Tests
117+
run: |
118+
bazelisk --batch test //test/integration/...
119+
- name: Gradle Build Generated Storage Client Library
120+
run: |
121+
echo "Building Storage lib from generated source..."
122+
mkdir /tmp/java-storage
123+
bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java
124+
tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage
125+
pushd /tmp/java-storage/google-cloud-storage-v2-java
126+
./gradlew clean build publishToMavenLocal sourcesJar allJars
127+
popd
128+
129+
- name: Gradle Build Generated Compute Client Library
130+
run: |
131+
echo "Building Compute lib from generated source..."
132+
mkdir /tmp/java-compute
133+
bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java
134+
tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute
135+
pushd /tmp/java-compute/google-cloud-compute-small-v1-java
136+
./gradlew clean build publishToMavenLocal sourcesJar allJars
137+
popd
92138
93139
lint:
94140
runs-on: ubuntu-latest
@@ -116,26 +162,6 @@ jobs:
116162
java-version: ${{ matrix.java }}
117163
distribution: temurin
118164
- run: java -version
119-
120-
- name: Bazel File Cache Setup
121-
id: cache-bazel
122-
uses: actions/cache@v3
123-
with:
124-
path: ~/.cache/bazel
125-
key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }}
126-
restore-keys: ${{ runner.os }}-
127-
- name: Bazel Cache Not Found
128-
if: steps.cache-bazel.outputs.cache-hit != 'true'
129-
run: |
130-
echo "No cache found."
131-
- name: Bazel Cache Found
132-
if: steps.cache-bazel.outputs.cache-hit == 'true'
133-
run: |
134-
echo -n "Cache found. Cache size: "
135-
du -sh ~/.cache/bazel
136-
echo "If the cache seems broken, update the root WORKSPACE file with a trivial change."
137-
echo "The old cache will disappear after 7 days."
138-
139165
- name: Install maven modules
140166
run: |
141167
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip

.github/workflows/ci.yaml

-115
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ target/
1414

1515
# Vscode Settings
1616
.vscode/settings.json
17+
18+
*.iml

0 commit comments

Comments
 (0)