Skip to content

Commit 1f63287

Browse files
chore: update common templates (#1018)
1 parent a45b585 commit 1f63287

File tree

9 files changed

+370
-23
lines changed

9 files changed

+370
-23
lines changed

.kokoro/build.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@ scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
2020
## cd to the parent directory, i.e. the root of the git repo
2121
cd ${scriptDir}/..
2222

23+
# include common functions
24+
source ${scriptDir}/common.sh
25+
2326
# Print out Java version
2427
java -version
2528
echo ${JOB_TYPE}
2629

27-
mvn install -B -V \
28-
-DskipTests=true \
29-
-Dclirr.skip=true \
30-
-Denforcer.skip=true \
31-
-Dmaven.javadoc.skip=true \
32-
-Dgcloud.download.skip=true \
33-
-T 1C
30+
# attempt to install 3 times with exponential backoff (starting with 10 seconds)
31+
retry_with_backoff 3 10 \
32+
mvn install -B -V \
33+
-DskipTests=true \
34+
-Dclirr.skip=true \
35+
-Denforcer.skip=true \
36+
-Dmaven.javadoc.skip=true \
37+
-Dgcloud.download.skip=true \
38+
-T 1C
3439

3540
# if GOOGLE_APPLICATION_CREDIENTIALS is specified as a relative path prepend Kokoro root directory onto it
3641
if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then

.kokoro/common.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# Copyright 2020 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+
16+
# set -eo pipefail
17+
18+
function retry_with_backoff {
19+
attempts_left=$1
20+
sleep_seconds=$2
21+
shift 2
22+
command=$@
23+
24+
echo "${command}"
25+
${command}
26+
exit_code=$?
27+
28+
if [[ $exit_code == 0 ]]
29+
then
30+
return 0
31+
fi
32+
33+
# failure
34+
if [[ ${attempts_left} > 0 ]]
35+
then
36+
echo "failure (${exit_code}), sleeping ${sleep_seconds}..."
37+
sleep ${sleep_seconds}
38+
new_attempts=$((${attempts_left} - 1))
39+
new_sleep=$((${sleep_seconds} * 2))
40+
retry_with_backoff ${new_attempts} ${new_sleep} ${command}
41+
fi
42+
43+
return $exit_code
44+
}

.kokoro/dependencies.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515

1616
set -eo pipefail
1717

18-
cd github/google-http-java-client/
18+
## Get the directory of the build script
19+
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
20+
## cd to the parent directory, i.e. the root of the git repo
21+
cd ${scriptDir}/..
22+
23+
# include common functions
24+
source ${scriptDir}/common.sh
1925

2026
# Print out Java
2127
java -version
@@ -24,8 +30,9 @@ echo $JOB_TYPE
2430
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"
2531

2632
# this should run maven enforcer
27-
mvn install -B -V \
28-
-DskipTests=true \
29-
-Dclirr.skip=true
33+
retry_with_backoff 3 10 \
34+
mvn install -B -V \
35+
-DskipTests=true \
36+
-Dclirr.skip=true
3037

3138
mvn -B dependency:analyze -DfailOnWarning=true

.kokoro/linkage-monitor.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@ set -eo pipefail
1717
# Display commands being run.
1818
set -x
1919

20-
cd github/google-http-java-client/
20+
## Get the directory of the build script
21+
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
22+
## cd to the parent directory, i.e. the root of the git repo
23+
cd ${scriptDir}/..
24+
25+
# include common functions
26+
source ${scriptDir}/common.sh
2127

2228
# Print out Java version
2329
java -version
2430
echo ${JOB_TYPE}
2531

26-
mvn install -B -V \
27-
-DskipTests=true \
28-
-Dclirr.skip=true \
29-
-Denforcer.skip=true \
30-
-Dmaven.javadoc.skip=true \
31-
-Dgcloud.download.skip=true
32+
# attempt to install 3 times with exponential backoff (starting with 10 seconds)
33+
retry_with_backoff 3 10 \
34+
mvn install -B -V \
35+
-DskipTests=true \
36+
-Dclirr.skip=true \
37+
-Denforcer.skip=true \
38+
-Dmaven.javadoc.skip=true \
39+
-Dgcloud.download.skip=true
3240

3341
# Kokoro job cloud-opensource-java/ubuntu/linkage-monitor-gcs creates this JAR
3442
JAR=linkage-monitor-latest-all-deps.jar

samples/install-without-bom/pom.xml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.cloud</groupId>
5+
<artifactId>google-http-client-install-without-bom</artifactId>
6+
<packaging>jar</packaging>
7+
<name>Google Google HTTP Java Client Install Without Bom</name>
8+
<url>https://github.com/googleapis/google-http-java-client</url>
9+
10+
<!--
11+
The parent pom defines common style checks and testing strategies for our samples.
12+
Removing or replacing it should not affect the execution of the samples in anyway.
13+
-->
14+
<parent>
15+
<groupId>com.google.cloud.samples</groupId>
16+
<artifactId>shared-configuration</artifactId>
17+
<version>1.0.12</version>
18+
</parent>
19+
20+
<properties>
21+
<maven.compiler.target>1.8</maven.compiler.target>
22+
<maven.compiler.source>1.8</maven.compiler.source>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
</properties>
25+
26+
27+
<dependencies>
28+
<!-- [START google-http-client_install_without_bom] -->
29+
<dependency>
30+
<groupId>com.google.http-client</groupId>
31+
<artifactId>google-http-client</artifactId>
32+
<version></version>
33+
</dependency>
34+
<!-- [END google-http-client_install_without_bom] -->
35+
36+
<dependency>
37+
<groupId>junit</groupId>
38+
<artifactId>junit</artifactId>
39+
<version>4.13</version>
40+
<scope>test</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>com.google.truth</groupId>
44+
<artifactId>truth</artifactId>
45+
<version>1.0.1</version>
46+
<scope>test</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
<!-- compile and run all snippet tests -->
51+
<build>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.codehaus.mojo</groupId>
55+
<artifactId>build-helper-maven-plugin</artifactId>
56+
<version>3.1.0</version>
57+
<executions>
58+
<execution>
59+
<id>add-snippets-source</id>
60+
<goals>
61+
<goal>add-source</goal>
62+
</goals>
63+
<configuration>
64+
<sources>
65+
<source>../snippets/src/main/java</source>
66+
</sources>
67+
</configuration>
68+
</execution>
69+
<execution>
70+
<id>add-snippets-tests</id>
71+
<goals>
72+
<goal>add-test-source</goal>
73+
</goals>
74+
<configuration>
75+
<sources>
76+
<source>../snippets/src/test/java</source>
77+
</sources>
78+
</configuration>
79+
</execution>
80+
</executions>
81+
</plugin>
82+
</plugins>
83+
</build>
84+
</project>

samples/pom.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.cloud</groupId>
5+
<artifactId>google-cloud-google-http-client-samples</artifactId>
6+
<version>0.0.1-SNAPSHOT</version><!-- This artifact should not be released -->
7+
<packaging>pom</packaging>
8+
<name>Google Google HTTP Java Client Samples Parent</name>
9+
<url>https://github.com/googleapis/google-http-java-client</url>
10+
<description>
11+
Java idiomatic client for Google Cloud Platform services.
12+
</description>
13+
14+
<!--
15+
The parent pom defines common style checks and testing strategies for our samples.
16+
Removing or replacing it should not affect the execution of the samples in anyway.
17+
-->
18+
<parent>
19+
<groupId>com.google.cloud.samples</groupId>
20+
<artifactId>shared-configuration</artifactId>
21+
<version>1.0.12</version>
22+
</parent>
23+
24+
<properties>
25+
<maven.compiler.target>1.8</maven.compiler.target>
26+
<maven.compiler.source>1.8</maven.compiler.source>
27+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
28+
</properties>
29+
30+
<modules>
31+
<module>install-without-bom</module>
32+
<module>snapshot</module>
33+
<module>snippets</module>
34+
</modules>
35+
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.apache.maven.plugins</groupId>
40+
<artifactId>maven-deploy-plugin</artifactId>
41+
<version>2.8.2</version>
42+
<configuration>
43+
<skip>true</skip>
44+
</configuration>
45+
</plugin>
46+
<plugin>
47+
<groupId>org.sonatype.plugins</groupId>
48+
<artifactId>nexus-staging-maven-plugin</artifactId>
49+
<version>1.6.8</version>
50+
<configuration>
51+
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
52+
</configuration>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
</project>

samples/snapshot/pom.xml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.google.cloud</groupId>
5+
<artifactId>google-http-client-snapshot</artifactId>
6+
<packaging>jar</packaging>
7+
<name>Google Google HTTP Java Client Snapshot Samples</name>
8+
<url>https://github.com/googleapis/google-http-java-client</url>
9+
10+
<!--
11+
The parent pom defines common style checks and testing strategies for our samples.
12+
Removing or replacing it should not affect the execution of the samples in anyway.
13+
-->
14+
<parent>
15+
<groupId>com.google.cloud.samples</groupId>
16+
<artifactId>shared-configuration</artifactId>
17+
<version>1.0.12</version>
18+
</parent>
19+
20+
<properties>
21+
<maven.compiler.target>1.8</maven.compiler.target>
22+
<maven.compiler.source>1.8</maven.compiler.source>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
</properties>
25+
26+
<!-- {x-version-update-start::current} -->
27+
<dependencies>
28+
<dependency>
29+
<groupId>com.google.http-client</groupId>
30+
<artifactId>google-http-client</artifactId>
31+
<version></version>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>junit</groupId>
36+
<artifactId>junit</artifactId>
37+
<version>4.13</version>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.google.truth</groupId>
42+
<artifactId>truth</artifactId>
43+
<version>1.0.1</version>
44+
<scope>test</scope>
45+
</dependency>
46+
</dependencies>
47+
<!-- {x-version-update-end} -->
48+
49+
<!-- compile and run all snippet tests -->
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.codehaus.mojo</groupId>
54+
<artifactId>build-helper-maven-plugin</artifactId>
55+
<version>3.1.0</version>
56+
<executions>
57+
<execution>
58+
<id>add-snippets-source</id>
59+
<goals>
60+
<goal>add-source</goal>
61+
</goals>
62+
<configuration>
63+
<sources>
64+
<source>../snippets/src/main/java</source>
65+
</sources>
66+
</configuration>
67+
</execution>
68+
<execution>
69+
<id>add-snippets-tests</id>
70+
<goals>
71+
<goal>add-test-source</goal>
72+
</goals>
73+
<configuration>
74+
<sources>
75+
<source>../snippets/src/test/java</source>
76+
</sources>
77+
</configuration>
78+
</execution>
79+
</executions>
80+
</plugin>
81+
</plugins>
82+
</build>
83+
</project>

0 commit comments

Comments
 (0)