|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2020 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 | +# Presubmit to ensure the dependencies of the Google Libraries BOM, with the modification of change |
| 17 | +# in the PR, pick up the highest versions among transitive dependencies. |
| 18 | +# https://maven.apache.org/enforcer/enforcer-rules/requireUpperBoundDeps.html |
| 19 | +set -eo pipefail |
| 20 | +# Display commands being run. |
| 21 | +set -x |
| 22 | + |
| 23 | +CORE_LIBRARY_ARTIFACT=$1 |
| 24 | +CLIENT_LIBRARY=$2 |
| 25 | +## Get the directory of the build script |
| 26 | +scriptDir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" |
| 27 | +## cd to the parent directory, i.e. the root of the git repo |
| 28 | +cd "${scriptDir}"/.. |
| 29 | + |
| 30 | +CORE_VERSION=$( ./gradlew -q properties | grep '^version: ' | cut -d' ' -f2 ) |
| 31 | +echo "$CORE_VERSION" |
| 32 | + |
| 33 | +# Publish api-common to local maven to make it available for downstream libraries |
| 34 | +./gradlew publishToMavenLocal |
| 35 | + |
| 36 | +# Round 1 |
| 37 | +# Check this java core library against HEAD of java-shared dependencies |
| 38 | + |
| 39 | +git clone "https://github.com/googleapis/java-shared-dependencies.git" --depth=1 |
| 40 | +pushd java-shared-dependencies/first-party-dependencies |
| 41 | + |
| 42 | +# replace version |
| 43 | +xmllint --shell pom.xml << EOF |
| 44 | +setns x=http://maven.apache.org/POM/4.0.0 |
| 45 | +cd .//x:artifactId[text()="${CORE_LIBRARY_ARTIFACT}"] |
| 46 | +cd ../x:version |
| 47 | +set ${CORE_VERSION} |
| 48 | +save pom.xml |
| 49 | +EOF |
| 50 | + |
| 51 | +cd .. |
| 52 | +mvn verify install -B -V -ntp -fae \ |
| 53 | +-DskipTests=true \ |
| 54 | +-Dmaven.javadoc.skip=true \ |
| 55 | +-Dgcloud.download.skip=true \ |
| 56 | +-Denforcer.skip=true |
| 57 | + |
| 58 | +SHARED_DEPS_VERSION_POM=pom.xml |
| 59 | +# Namespace (xmlns) prevents xmllint from specifying tag names in XPath |
| 60 | +SHARED_DEPS_VERSION=$(sed -e 's/xmlns=".*"//' ${SHARED_DEPS_VERSION_POM} | xmllint --xpath '/project/version/text()' -) |
| 61 | + |
| 62 | +if [ -z "${SHARED_DEPS_VERSION}" ]; then |
| 63 | + echo "Version is not found in ${SHARED_DEPS_VERSION_POM}" |
| 64 | + exit 1 |
| 65 | +fi |
| 66 | + |
| 67 | +# Round 2 |
| 68 | +# Check this BOM against java client libraries |
| 69 | +git clone "https://github.com/googleapis/java-${CLIENT_LIBRARY}.git" --depth=1 |
| 70 | +pushd java-"${CLIENT_LIBRARY}" |
| 71 | + |
| 72 | +if [[ $CLIENT_LIBRARY == "bigtable" ]]; then |
| 73 | + pushd google-cloud-bigtable-deps-bom |
| 74 | +fi |
| 75 | + |
| 76 | +# replace version |
| 77 | +xmllint --shell pom.xml << EOF |
| 78 | +setns x=http://maven.apache.org/POM/4.0.0 |
| 79 | +cd .//x:artifactId[text()="google-cloud-shared-dependencies"] |
| 80 | +cd ../x:version |
| 81 | +set ${SHARED_DEPS_VERSION} |
| 82 | +save pom.xml |
| 83 | +EOF |
| 84 | + |
| 85 | +if [[ $CLIENT_LIBRARY == "bigtable" ]]; then |
| 86 | + popd |
| 87 | +fi |
| 88 | + |
| 89 | +mvn verify install -B -V -ntp -fae \ |
| 90 | +-Dmaven.javadoc.skip=true \ |
| 91 | +-Dgcloud.download.skip=true \ |
| 92 | +-Denforcer.skip=true |
0 commit comments