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