xref: /aosp_15_r20/external/google-auth-library-java/.kokoro/downstream-client-library-check.sh (revision af546375c95127f07cb26dd492629ccb2e8b1be1)
1*af546375SCole Faust#!/bin/bash
2*af546375SCole Faust# Copyright 2022 Google LLC
3*af546375SCole Faust#
4*af546375SCole Faust# Licensed under the Apache License, Version 2.0 (the "License");
5*af546375SCole Faust# you may not use this file except in compliance with the License.
6*af546375SCole Faust# You may obtain a copy of the License at
7*af546375SCole Faust#
8*af546375SCole Faust#      http://www.apache.org/licenses/LICENSE-2.0
9*af546375SCole Faust#
10*af546375SCole Faust# Unless required by applicable law or agreed to in writing, software
11*af546375SCole Faust# distributed under the License is distributed on an "AS IS" BASIS,
12*af546375SCole Faust# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*af546375SCole Faust# See the License for the specific language governing permissions and
14*af546375SCole Faust# limitations under the License.
15*af546375SCole Faust
16*af546375SCole Faustset -eo pipefail
17*af546375SCole Faust# Display commands being run.
18*af546375SCole Faustset -x
19*af546375SCole Faust
20*af546375SCole FaustCORE_LIBRARY_ARTIFACT=$1
21*af546375SCole FaustCLIENT_LIBRARY=$2
22*af546375SCole Faust## Get the directory of the build script
23*af546375SCole FaustscriptDir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
24*af546375SCole Faust## cd to the parent directory, i.e. the root of the git repo
25*af546375SCole Faustcd "${scriptDir}"/..
26*af546375SCole Faust
27*af546375SCole Faust# Make java core library artifacts available for 'mvn install' at the bottom
28*af546375SCole Faustmvn verify install -B -V -ntp -fae \
29*af546375SCole Faust-DskipTests=true \
30*af546375SCole Faust-Dmaven.javadoc.skip=true \
31*af546375SCole Faust-Dgcloud.download.skip=true \
32*af546375SCole Faust-Denforcer.skip=true
33*af546375SCole Faust
34*af546375SCole Faust# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
35*af546375SCole FaustCORE_VERSION=$(sed -e 's/xmlns=".*"//' pom.xml | xmllint --xpath '/project/version/text()' -)
36*af546375SCole Faust
37*af546375SCole Faustif [ -z "${CORE_VERSION}" ]; then
38*af546375SCole Faust  echo "Version is not found in ${CORE_VERSION_POM}"
39*af546375SCole Faust  exit 1
40*af546375SCole Faustfi
41*af546375SCole Faustecho "Version: ${CORE_VERSION}"
42*af546375SCole Faust
43*af546375SCole Faust# Round 1
44*af546375SCole Faust# Check this java core library against HEAD of java-shared dependencies
45*af546375SCole Faust
46*af546375SCole Faustgit clone "https://github.com/googleapis/java-shared-dependencies.git" --depth=1
47*af546375SCole Faustpushd java-shared-dependencies/first-party-dependencies
48*af546375SCole Faust
49*af546375SCole Faust# replace version
50*af546375SCole Faustxmllint --shell pom.xml << EOF
51*af546375SCole Faustsetns x=http://maven.apache.org/POM/4.0.0
52*af546375SCole Faustcd .//x:artifactId[text()="${CORE_LIBRARY_ARTIFACT}"]
53*af546375SCole Faustcd ../x:version
54*af546375SCole Faustset ${CORE_VERSION}
55*af546375SCole Faustsave pom.xml
56*af546375SCole FaustEOF
57*af546375SCole Faust
58*af546375SCole Faust# run dependencies script
59*af546375SCole Faustcd ..
60*af546375SCole Faustmvn verify install -B -V -ntp -fae \
61*af546375SCole Faust-DskipTests=true \
62*af546375SCole Faust-Dmaven.javadoc.skip=true \
63*af546375SCole Faust-Dgcloud.download.skip=true \
64*af546375SCole Faust-Denforcer.skip=true
65*af546375SCole Faust
66*af546375SCole Faust# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
67*af546375SCole FaustSHARED_DEPS_VERSION=$(sed -e 's/xmlns=".*"//' pom.xml | xmllint --xpath '/project/version/text()' -)
68*af546375SCole Faust
69*af546375SCole Faustif [ -z "${SHARED_DEPS_VERSION}" ]; then
70*af546375SCole Faust  echo "Version is not found in ${SHARED_DEPS_VERSION_POM}"
71*af546375SCole Faust  exit 1
72*af546375SCole Faustfi
73*af546375SCole Faust
74*af546375SCole Faust# Round 2
75*af546375SCole Faust
76*af546375SCole Faust# Check this BOM against java client libraries
77*af546375SCole Faustgit clone "https://github.com/googleapis/java-${CLIENT_LIBRARY}.git" --depth=1
78*af546375SCole Faustpushd java-"${CLIENT_LIBRARY}"
79*af546375SCole Faust
80*af546375SCole Faustif [[ $CLIENT_LIBRARY == "bigtable" ]]; then
81*af546375SCole Faust  pushd google-cloud-bigtable-deps-bom
82*af546375SCole Faustfi
83*af546375SCole Faust
84*af546375SCole Faust# replace version
85*af546375SCole Faustxmllint --shell pom.xml << EOF
86*af546375SCole Faustsetns x=http://maven.apache.org/POM/4.0.0
87*af546375SCole Faustcd .//x:artifactId[text()="google-cloud-shared-dependencies"]
88*af546375SCole Faustcd ../x:version
89*af546375SCole Faustset ${SHARED_DEPS_VERSION}
90*af546375SCole Faustsave pom.xml
91*af546375SCole FaustEOF
92*af546375SCole Faust
93*af546375SCole Faustif [[ $CLIENT_LIBRARY == "bigtable" ]]; then
94*af546375SCole Faust  popd
95*af546375SCole Faustfi
96*af546375SCole Faust
97*af546375SCole Faustmvn verify install -B -V -ntp -fae \
98*af546375SCole Faust-Dmaven.javadoc.skip=true \
99*af546375SCole Faust-Dgcloud.download.skip=true \
100*af546375SCole Faust-Denforcer.skip=true
101