Skip to content

Commit b40b880

Browse files
committed
chore: Update to Protobuf-Java 4.27.4
1 parent 5456b52 commit b40b880

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.kokoro/build.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,81 @@ source ${scriptDir}/common.sh
2727
mvn -version
2828
echo ${JOB_TYPE}
2929

30+
# Store the current Java version since the version may change when installing sdk-platform-java
31+
current_java_home=$JAVA_HOME
32+
33+
# testing-infra-docker has Java 11 installed in java8 docker container. Use this as sdk-platform-java
34+
# needs Java 11+ to run with GraalVM. For GH actions, JAVA11_HOME does not exist and would skip this.
35+
if [ ! -z "${JAVA11_HOME}" ]; then
36+
export JAVA_HOME="${JAVA11_HOME}"
37+
export PATH=${JAVA_HOME}/bin:$PATH
38+
fi
39+
40+
# Get the current proto runtime version used in this repo
41+
CURRENT_PROTO_VERSION=$(mvn -ntp help:effective-pom |
42+
sed -n "/<artifactId>protobuf-java<\/artifactId>/,/<\/dependency>/ {
43+
/<version>/{
44+
s/<version>\(.*\)<\/version>/\1/p
45+
q
46+
}
47+
}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
48+
echo "The current proto version is: ${CURRENT_PROTO_VERSION}"
49+
50+
# Find the latest proto runtime version available
51+
LATEST_PROTO_VERSION="4.27.4"
52+
echo "The latest proto version is: ${LATEST_PROTO_VERSION}"
53+
54+
# Only reinstall shared-deps again to test for a newer proto version
55+
if [[ "${CURRENT_PROTO_VERSION}" != "${LATEST_PROTO_VERSION}" ]]; then
56+
pushd /tmp
57+
git clone https://github.com/googleapis/sdk-platform-java.git
58+
pushd sdk-platform-java
59+
pushd gapic-generator-java-pom-parent
60+
sed -i "/<protobuf.version>.*<\/protobuf.version>/s/\(.*<protobuf.version>\).*\(<\/protobuf.version>\)/\1${LATEST_PROTO_VERSION}\2/" pom.xml
61+
# sdk-platform-java
62+
popd
63+
64+
pushd sdk-platform-java-config
65+
# Get current Shared-Deps version in sdk-platform-java
66+
SHARED_DEPS_VERSION=$(mvn -ntp help:effective-pom |
67+
sed -n "/<artifactId>sdk-platform-java-config<\/artifactId>/,/<\/dependency>/ {
68+
/<version>/{
69+
s/<version>\(.*\)<\/version>/\1/p
70+
q
71+
}
72+
}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
73+
echo "Shared-Deps Version: ${SHARED_DEPS_VERSION}"
74+
# sdk-platform-java
75+
popd
76+
77+
mvn clean install -q -ntp \
78+
-DskipTests=true \
79+
-Dclirr.skip=true \
80+
-Denforcer.skip=true \
81+
-T 1C
82+
# /tmp
83+
popd
84+
85+
# Back to the original directory of the repo
86+
popd
87+
# Find all the poms with a reference to shared-deps and update to the new local version
88+
poms=($(find . -name pom.xml))
89+
for pom in "${poms[@]}"; do
90+
if grep -q "sdk-platform-java-config" "${pom}"; then
91+
echo "Updating the pom: ${pom} to use shared-deps version: ${SHARED_DEPS_VERSION}"
92+
sed -i "/<artifactId>sdk-platform-java-config<\/artifactId>/,/<\/parent>/ s/<version>.*<\/version>/<version>$SHARED_DEPS_VERSION<\/version>/" "${pom}"
93+
# xmlstarlet ed --inplace -N x="http://maven.apache.org/POM/4.0.0" \
94+
# -u "//x:project/x:parent[x:artifactId='sdk-platform-java-config']/x:version" \
95+
# -v "${SHARED_DEPS_VERSION}" \
96+
# "${pom}"
97+
fi
98+
done
99+
fi
100+
101+
# Reset back to the original Java version if changed
102+
export JAVA_HOME="${current_java_home}"
103+
export PATH=${JAVA_HOME}/bin:$PATH
104+
30105
# attempt to install 3 times with exponential backoff (starting with 10 seconds)
31106
retry_with_backoff 3 10 \
32107
mvn install -B -V -ntp \

0 commit comments

Comments
 (0)