diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 2341ce9a6..82e54b2a6 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -20,17 +20,22 @@ scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) ## cd to the parent directory, i.e. the root of the git repo cd ${scriptDir}/.. +# include common functions +source ${scriptDir}/common.sh + # Print out Java version java -version echo ${JOB_TYPE} -mvn install -B -V \ - -DskipTests=true \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -Dmaven.javadoc.skip=true \ - -Dgcloud.download.skip=true \ - -T 1C +# attempt to install 3 times with exponential backoff (starting with 10 seconds) +retry_with_backoff 3 10 \ + mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -Dmaven.javadoc.skip=true \ + -Dgcloud.download.skip=true \ + -T 1C # if GOOGLE_APPLICATION_CREDIENTIALS is specified as a relative path prepend Kokoro root directory onto it if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then diff --git a/.kokoro/common.sh b/.kokoro/common.sh new file mode 100644 index 000000000..8f09de5d3 --- /dev/null +++ b/.kokoro/common.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +function retry_with_backoff { + attempts_left=$1 + sleep_seconds=$2 + shift 2 + command=$@ + + + # store current flag state + flags=$- + + # allow a failures to continue + set +e + echo "${command}" + ${command} + exit_code=$? + + # restore "e" flag + if [[ ${flags} =~ e ]] + then set -e + else set +e + fi + + if [[ $exit_code == 0 ]] + then + return 0 + fi + + # failure + if [[ ${attempts_left} > 0 ]] + then + echo "failure (${exit_code}), sleeping ${sleep_seconds}..." + sleep ${sleep_seconds} + new_attempts=$((${attempts_left} - 1)) + new_sleep=$((${sleep_seconds} * 2)) + retry_with_backoff ${new_attempts} ${new_sleep} ${command} + fi + + return $exit_code +} diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh index 14279849a..0aade871c 100755 --- a/.kokoro/dependencies.sh +++ b/.kokoro/dependencies.sh @@ -15,7 +15,13 @@ set -eo pipefail -cd github/google-oauth-java-client/ +## Get the directory of the build script +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) +## cd to the parent directory, i.e. the root of the git repo +cd ${scriptDir}/.. + +# include common functions +source ${scriptDir}/common.sh # Print out Java java -version @@ -24,8 +30,9 @@ echo $JOB_TYPE export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" # this should run maven enforcer -mvn install -B -V \ - -DskipTests=true \ - -Dclirr.skip=true +retry_with_backoff 3 10 \ + mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true mvn -B dependency:analyze -DfailOnWarning=true diff --git a/.kokoro/linkage-monitor.sh b/.kokoro/linkage-monitor.sh index d906c0f73..759ab4e2c 100755 --- a/.kokoro/linkage-monitor.sh +++ b/.kokoro/linkage-monitor.sh @@ -17,18 +17,26 @@ set -eo pipefail # Display commands being run. set -x -cd github/google-oauth-java-client/ +## Get the directory of the build script +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) +## cd to the parent directory, i.e. the root of the git repo +cd ${scriptDir}/.. + +# include common functions +source ${scriptDir}/common.sh # Print out Java version java -version echo ${JOB_TYPE} -mvn install -B -V \ - -DskipTests=true \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -Dmaven.javadoc.skip=true \ - -Dgcloud.download.skip=true +# attempt to install 3 times with exponential backoff (starting with 10 seconds) +retry_with_backoff 3 10 \ + mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -Dmaven.javadoc.skip=true \ + -Dgcloud.download.skip=true # Kokoro job cloud-opensource-java/ubuntu/linkage-monitor-gcs creates this JAR JAR=linkage-monitor-latest-all-deps.jar diff --git a/.kokoro/nightly/integration.cfg b/.kokoro/nightly/integration.cfg index 8bf59c02e..ca0274800 100644 --- a/.kokoro/nightly/integration.cfg +++ b/.kokoro/nightly/integration.cfg @@ -6,11 +6,26 @@ env_vars: { value: "gcr.io/cloud-devrel-kokoro-resources/java8" } +env_vars: { + key: "JOB_TYPE" + value: "integration" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + env_vars: { key: "ENABLE_BUILD_COP" value: "true" } +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "keystore/73713_java_it_service_account" +} + before_action { fetch_keystore { keystore_resource { diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml new file mode 100644 index 000000000..c73488e6a --- /dev/null +++ b/samples/install-without-bom/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + com.google.cloud + google-oauth-client-install-without-bom + jar + Google Google OAuth Java Client Install Without Bom + https://github.com/googleapis/google-oauth-java-client + + + + com.google.cloud.samples + shared-configuration + 1.0.12 + + + + 1.8 + 1.8 + UTF-8 + + + + + + + com.google.oauth-client + google-oauth-client + + + + + + junit + junit + 4.13 + test + + + com.google.truth + truth + 1.0.1 + test + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.1.0 + + + add-snippets-source + + add-source + + + + ../snippets/src/main/java + + + + + add-snippets-tests + + add-test-source + + + + ../snippets/src/test/java + + + + + + + + diff --git a/samples/pom.xml b/samples/pom.xml new file mode 100644 index 000000000..c827f41b6 --- /dev/null +++ b/samples/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + com.google.cloud + google-cloud-google-oauth-client-samples + 0.0.1-SNAPSHOT + pom + Google Google OAuth Java Client Samples Parent + https://github.com/googleapis/google-oauth-java-client + + Java idiomatic client for Google Cloud Platform services. + + + + + com.google.cloud.samples + shared-configuration + 1.0.15 + + + + 1.8 + 1.8 + UTF-8 + + + + install-without-bom + snapshot + snippets + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + + true + + + + + diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml new file mode 100644 index 000000000..4a1a476e8 --- /dev/null +++ b/samples/snapshot/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + com.google.cloud + google-oauth-client-snapshot + jar + Google Google OAuth Java Client Snapshot Samples + https://github.com/googleapis/google-oauth-java-client + + + + com.google.cloud.samples + shared-configuration + 1.0.12 + + + + 1.8 + 1.8 + UTF-8 + + + + + + com.google.oauth-client + google-oauth-client + + + + + junit + junit + 4.13 + test + + + com.google.truth + truth + 1.0.1 + test + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.1.0 + + + add-snippets-source + + add-source + + + + ../snippets/src/main/java + + + + + add-snippets-tests + + add-test-source + + + + ../snippets/src/test/java + + + + + + + + \ No newline at end of file diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml new file mode 100644 index 000000000..ca8ee09b3 --- /dev/null +++ b/samples/snippets/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + com.google.cloud + google-oauth-client-snippets + jar + Google Google OAuth Java Client Snippets + https://github.com/googleapis/google-oauth-java-client + + + + com.google.cloud.samples + shared-configuration + 1.0.12 + + + + 1.8 + 1.8 + UTF-8 + + + + + + + + com.google.cloud + libraries-bom + + pom + import + + + + + + + com.google.oauth-client + google-oauth-client + + + + + junit + junit + 4.13 + test + + + com.google.truth + truth + 1.0.1 + test + + + diff --git a/synth.metadata b/synth.metadata index 0f150a7b4..b3b362ba9 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,11 +1,17 @@ { - "updateTime": "2020-03-16T21:33:50.666509Z", "sources": [ { - "template": { - "name": "java_library", - "origin": "synthtool.gcp", - "version": "2020.2.4" + "git": { + "name": ".", + "remote": "https://github.com/googleapis/google-oauth-java-client.git", + "sha": "c538e8fa02391f172ccd3cb007466432ae78db51" + } + }, + { + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "682c0c37d1054966ca662a44259e96cc7aea4413" } } ]