|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2022 Google LLC |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -eo pipefail |
| 17 | +# Display commands being run. |
| 18 | +set -x |
| 19 | + |
| 20 | + |
| 21 | +CORE_LIBRARY_ARTIFACT=$1 |
| 22 | +CLIENT_LIBRARY=$2 |
| 23 | +## Get the directory of the build script |
| 24 | +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) |
| 25 | + |
| 26 | +# Building this library locally requires a one time set up of google-play-services-basement |
| 27 | +mkdir /tmp/foo && cd /tmp/foo |
| 28 | +wget https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-basement/8.3.0/play-services-basement-8.3.0.aar |
| 29 | +unzip play-services-basement-8.3.0.aar |
| 30 | +mvn install:install-file \ |
| 31 | + -Dfile=classes.jar \ |
| 32 | + -DgroupId=com.google.android.google-play-services \ |
| 33 | + -DartifactId=google-play-services \ |
| 34 | + -Dversion=1 \ |
| 35 | + -Dpackaging=jar |
| 36 | + |
| 37 | +## cd to the parent directory, i.e. the root of the git repo |
| 38 | +cd ${scriptDir}/.. |
| 39 | + |
| 40 | +# Make java core library artifacts available for 'mvn validate' at the bottom |
| 41 | +mvn verify install -B -V -ntp -fae \ |
| 42 | +-DskipTests=true \ |
| 43 | +-Dmaven.javadoc.skip=true \ |
| 44 | +-Dgcloud.download.skip=true \ |
| 45 | +-Denforcer.skip=true |
| 46 | + |
| 47 | +# Read the current version of this java core library in the POM. Example version: '0.116.1-alpha-SNAPSHOT' |
| 48 | +CORE_VERSION_POM=pom.xml |
| 49 | +# Namespace (xmlns) prevents xmllint from specifying tag names in XPath |
| 50 | +CORE_VERSION=`sed -e 's/xmlns=".*"//' ${CORE_VERSION_POM} | xmllint --xpath '/project/version/text()' -` |
| 51 | + |
| 52 | +if [ -z "${CORE_VERSION}" ]; then |
| 53 | + echo "Version is not found in ${CORE_VERSION_POM}" |
| 54 | + exit 1 |
| 55 | +fi |
| 56 | +echo "Version: ${CORE_VERSION}" |
| 57 | + |
| 58 | +# Round 1 |
| 59 | +# Check this java core library against HEAD of java-shared dependencies |
| 60 | + |
| 61 | +git clone "https://github.com/googleapis/java-shared-dependencies.git" --depth=1 |
| 62 | +pushd java-shared-dependencies/first-party-dependencies |
| 63 | + |
| 64 | +# replace version |
| 65 | +xmllint --shell <(cat pom.xml) << EOF |
| 66 | +setns x=http://maven.apache.org/POM/4.0.0 |
| 67 | +cd .//x:artifactId[text()="${CORE_LIBRARY_ARTIFACT}"] |
| 68 | +cd ../x:version |
| 69 | +set ${CORE_VERSION} |
| 70 | +save pom.xml |
| 71 | +EOF |
| 72 | + |
| 73 | +# run dependencies script |
| 74 | +cd .. |
| 75 | +mvn verify install -B -V -ntp -fae \ |
| 76 | +-DskipTests=true \ |
| 77 | +-Dmaven.javadoc.skip=true \ |
| 78 | +-Dgcloud.download.skip=true \ |
| 79 | +-Denforcer.skip=true |
| 80 | + |
| 81 | +SHARED_DEPS_VERSION_POM=pom.xml |
| 82 | +# Namespace (xmlns) prevents xmllint from specifying tag names in XPath |
| 83 | +SHARED_DEPS_VERSION=`sed -e 's/xmlns=".*"//' ${SHARED_DEPS_VERSION_POM} | xmllint --xpath '/project/version/text()' -` |
| 84 | + |
| 85 | +if [ -z "${SHARED_DEPS_VERSION}" ]; then |
| 86 | + echo "Version is not found in ${SHARED_DEPS_VERSION_POM}" |
| 87 | + exit 1 |
| 88 | +fi |
| 89 | + |
| 90 | +# Round 2 |
| 91 | + |
| 92 | +# Check this BOM against java client libraries |
| 93 | +git clone "https://github.com/googleapis/java-${CLIENT_LIBRARY}.git" --depth=1 |
| 94 | +pushd java-${CLIENT_LIBRARY} |
| 95 | + |
| 96 | +if [[ $CLIENT_LIBRARY == "bigtable" ]]; then |
| 97 | + pushd google-cloud-bigtable-deps-bom |
| 98 | +fi |
| 99 | + |
| 100 | +# replace version |
| 101 | +xmllint --shell <(cat pom.xml) << EOF |
| 102 | +setns x=http://maven.apache.org/POM/4.0.0 |
| 103 | +cd .//x:artifactId[text()="google-cloud-shared-dependencies"] |
| 104 | +cd ../x:version |
| 105 | +set ${SHARED_DEPS_VERSION} |
| 106 | +save pom.xml |
| 107 | +EOF |
| 108 | + |
| 109 | +if [[ $CLIENT_LIBRARY == "bigtable" ]]; then |
| 110 | + popd |
| 111 | +fi |
| 112 | + |
| 113 | +mvn verify install -B -V -ntp -fae \ |
| 114 | +-Dmaven.javadoc.skip=true \ |
| 115 | +-Dgcloud.download.skip=true \ |
| 116 | +-Denforcer.skip=true |
0 commit comments