Skip to content

Commit

Permalink
samples: add multi-module samples module to bq client (#248)
Browse files Browse the repository at this point in the history
* samples: add multi-module samples module to bq client to enable testing against SNAPSHOT

* update based on comments

* update commit msg

* fix build error and kokoro path

* update test file path

* fix build error

* remove redundant deps

* update samples build script to work for all 3 samples modules

* revert copyright year
  • Loading branch information
stephaniewang526 committed Mar 27, 2020
1 parent 5904a65 commit 5b38a85
Show file tree
Hide file tree
Showing 84 changed files with 2,363 additions and 62 deletions.
22 changes: 19 additions & 3 deletions .kokoro/run_samples_tests.sh
Expand Up @@ -20,19 +20,35 @@ set -eo pipefail
echo "********** MAVEN INFO ***********"
mvn -v

# 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

# Setup required env variables
source ${KOKORO_GFILE_DIR}/bigquery_secrets.txt
echo "********** Successfully Set All Environment Variables **********"

# 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

# Activate service account
gcloud auth activate-service-account \
--key-file="$GOOGLE_APPLICATION_CREDENTIALS" \
--project="$GOOGLE_CLOUD_PROJECT"

# Get the directory of the build script
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
# Move into the samples directory
cd ${scriptDir}/../samples/
cd samples/

echo -e "\n******************** RUNNING SAMPLE TESTS ********************"

Expand Down
101 changes: 101 additions & 0 deletions samples/install-without-bom/pom.xml
@@ -0,0 +1,101 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
~ 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.
-->

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>bigquery-install-without-bom</artifactId>
<packaging>jar</packaging>
<name>Google BigQuery Install Without Bom</name>
<url>https://github.com/googleapis/java-bigquery</url>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.12</version>
</parent>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<dependencies>
<!-- [START bigquery_install_without_bom] -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.110.0</version>
</dependency>
<!-- [END bigquery_install_without_bom] -->

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<!-- compile and run all snippet tests -->
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>add-snippets-source</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../snippets/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-snippets-tests</id>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>../snippets/src/test/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
78 changes: 20 additions & 58 deletions samples/pom.xml
@@ -1,23 +1,31 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
~ Copyright 2019 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
~ 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.
-->
<project>

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.bigquery</groupId>
<artifactId>bigquery-google-cloud-samples</artifactId>
<packaging>jar</packaging>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery-samples</artifactId>
<version>0.0.1-SNAPSHOT</version><!-- This artifact should not be released -->
<packaging>pom</packaging>
<name>Google BigQuery Samples Parent</name>
<url>https://github.com/googleapis/java-bigquery</url>
<description>
Java idiomatic client for Google Cloud Platform services.
</description>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Expand All @@ -26,7 +34,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.13</version>
<version>1.0.12</version>
</parent>

<properties>
Expand All @@ -35,57 +43,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!-- [START bigquery_java_dependencies] -->
<!-- Using libraries-bom to manage versions.
See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>4.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
</dependency>
<!-- [END bigquery_java_dependencies] -->
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>1.54.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>1.93.3</version>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>0.20.0</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>install-without-bom</module>
<module>snapshot</module>
<module>snippets</module>
</modules>

<build>
<plugins>
Expand All @@ -107,4 +69,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
100 changes: 100 additions & 0 deletions samples/snapshot/pom.xml
@@ -0,0 +1,100 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
~ 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.
-->

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>bigquery-snapshot</artifactId>
<packaging>jar</packaging>
<name>Google BigQuery Snapshot Samples</name>
<url>https://github.com/googleapis/java-bigquery</url>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.12</version>
</parent>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!-- {x-version-update-start::current} -->
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.110.1-SNAPSHOT</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
<!-- {x-version-update-end} -->
</dependencies>

<!-- compile and run all snippet tests -->
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>add-snippets-source</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../snippets/src/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-snippets-tests</id>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>../snippets/src/test/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 5b38a85

Please sign in to comment.