xref: /aosp_15_r20/external/google-auth-library-java/.kokoro/downstream-client-library-check.sh (revision af546375c95127f07cb26dd492629ccb2e8b1be1)
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
16set -eo pipefail
17# Display commands being run.
18set -x
19
20CORE_LIBRARY_ARTIFACT=$1
21CLIENT_LIBRARY=$2
22## Get the directory of the build script
23scriptDir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
24## cd to the parent directory, i.e. the root of the git repo
25cd "${scriptDir}"/..
26
27# Make java core library artifacts available for 'mvn install' at the bottom
28mvn verify install -B -V -ntp -fae \
29-DskipTests=true \
30-Dmaven.javadoc.skip=true \
31-Dgcloud.download.skip=true \
32-Denforcer.skip=true
33
34# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
35CORE_VERSION=$(sed -e 's/xmlns=".*"//' pom.xml | xmllint --xpath '/project/version/text()' -)
36
37if [ -z "${CORE_VERSION}" ]; then
38  echo "Version is not found in ${CORE_VERSION_POM}"
39  exit 1
40fi
41echo "Version: ${CORE_VERSION}"
42
43# Round 1
44# Check this java core library against HEAD of java-shared dependencies
45
46git clone "https://github.com/googleapis/java-shared-dependencies.git" --depth=1
47pushd java-shared-dependencies/first-party-dependencies
48
49# replace version
50xmllint --shell pom.xml << EOF
51setns x=http://maven.apache.org/POM/4.0.0
52cd .//x:artifactId[text()="${CORE_LIBRARY_ARTIFACT}"]
53cd ../x:version
54set ${CORE_VERSION}
55save pom.xml
56EOF
57
58# run dependencies script
59cd ..
60mvn verify install -B -V -ntp -fae \
61-DskipTests=true \
62-Dmaven.javadoc.skip=true \
63-Dgcloud.download.skip=true \
64-Denforcer.skip=true
65
66# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
67SHARED_DEPS_VERSION=$(sed -e 's/xmlns=".*"//' pom.xml | xmllint --xpath '/project/version/text()' -)
68
69if [ -z "${SHARED_DEPS_VERSION}" ]; then
70  echo "Version is not found in ${SHARED_DEPS_VERSION_POM}"
71  exit 1
72fi
73
74# Round 2
75
76# Check this BOM against java client libraries
77git clone "https://github.com/googleapis/java-${CLIENT_LIBRARY}.git" --depth=1
78pushd java-"${CLIENT_LIBRARY}"
79
80if [[ $CLIENT_LIBRARY == "bigtable" ]]; then
81  pushd google-cloud-bigtable-deps-bom
82fi
83
84# replace version
85xmllint --shell pom.xml << EOF
86setns x=http://maven.apache.org/POM/4.0.0
87cd .//x:artifactId[text()="google-cloud-shared-dependencies"]
88cd ../x:version
89set ${SHARED_DEPS_VERSION}
90save pom.xml
91EOF
92
93if [[ $CLIENT_LIBRARY == "bigtable" ]]; then
94  popd
95fi
96
97mvn verify install -B -V -ntp -fae \
98-Dmaven.javadoc.skip=true \
99-Dgcloud.download.skip=true \
100-Denforcer.skip=true
101