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