xref: /aosp_15_r20/external/google-auth-library-java/.kokoro/dependencies.sh (revision af546375c95127f07cb26dd492629ccb2e8b1be1)
1*af546375SCole Faust#!/bin/bash
2*af546375SCole Faust# Copyright 2019 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 Faustshopt -s nullglob
18*af546375SCole Faust
19*af546375SCole Faust## Get the directory of the build script
20*af546375SCole FaustscriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
21*af546375SCole Faust## cd to the parent directory, i.e. the root of the git repo
22*af546375SCole Faustcd ${scriptDir}/..
23*af546375SCole Faust
24*af546375SCole Faust# include common functions
25*af546375SCole Faustsource ${scriptDir}/common.sh
26*af546375SCole Faust
27*af546375SCole Faust# Print out Java
28*af546375SCole Faustjava -version
29*af546375SCole Faustecho $JOB_TYPE
30*af546375SCole Faust
31*af546375SCole Faustfunction determineMavenOpts() {
32*af546375SCole Faust  local javaVersion=$(
33*af546375SCole Faust    # filter down to the version line, then pull out the version between quotes,
34*af546375SCole Faust    # then trim the version number down to its minimal number (removing any
35*af546375SCole Faust    # update or suffix number).
36*af546375SCole Faust    java -version 2>&1 | grep "version" \
37*af546375SCole Faust      | sed -E 's/^.*"(.*?)".*$/\1/g' \
38*af546375SCole Faust      | sed -E 's/^(1\.[0-9]\.0).*$/\1/g'
39*af546375SCole Faust  )
40*af546375SCole Faust
41*af546375SCole Faust  if [[ $javaVersion == 17* ]]
42*af546375SCole Faust    then
43*af546375SCole Faust      # MaxPermSize is no longer supported as of jdk 17
44*af546375SCole Faust      echo -n "-Xmx1024m"
45*af546375SCole Faust  else
46*af546375SCole Faust      echo -n "-Xmx1024m -XX:MaxPermSize=128m"
47*af546375SCole Faust  fi
48*af546375SCole Faust}
49*af546375SCole Faust
50*af546375SCole Faustexport MAVEN_OPTS=$(determineMavenOpts)
51*af546375SCole Faust
52*af546375SCole Faust# this should run maven enforcer
53*af546375SCole Faustretry_with_backoff 3 10 \
54*af546375SCole Faust  mvn install -B -V -ntp \
55*af546375SCole Faust    -DskipTests=true \
56*af546375SCole Faust    -Dmaven.javadoc.skip=true \
57*af546375SCole Faust    -Dclirr.skip=true
58*af546375SCole Faust
59*af546375SCole Faustmvn -B dependency:analyze -DfailOnWarning=true
60