Skip to content

Commit

Permalink
chore: Add Maven build (#1562)
Browse files Browse the repository at this point in the history
Co-authored-by: Blake Li <blakeli@google.com>
  • Loading branch information
meltsufin and blakeli0 authored Jun 9, 2022
1 parent 26ad191 commit ad1a767
Show file tree
Hide file tree
Showing 12 changed files with 640 additions and 11 deletions.
19 changes: 19 additions & 0 deletions gax-java/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ on:
pull_request:
name: ci
jobs:
maven-units:
name: "maven unit tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: zulu
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: zulu
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- run: printenv
- run: .kokoro/maven-build.sh
env:
JOB_TYPE: test
units-java11:
name: "units (11)"
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions gax-java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build
.gradle
tmp_docs
bazel-*
target

# Eclipse
.apt_generated*
Expand All @@ -21,5 +22,3 @@ out
*.sw*
*.vim

# Auto-generated files.
gax/src/main/resources/dependencies.properties
61 changes: 61 additions & 0 deletions gax-java/.kokoro/maven-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# Copyright 2018 Google Inc.
#
# 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.

set -eo pipefail

scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
# cd to the parent directory, i.e. the root of the git repo
cd ${scriptDir}/..

echo $JOB_TYPE

function setJava() {
export JAVA_HOME=$1
export PATH=${JAVA_HOME}/bin:$PATH
}

# This project requires compiling the classes in JDK 11 or higher for GraalVM
# classes. Compiling this project with Java 8 or earlier would fail with "class
# file has wrong version 55.0, should be 53.0" and "unrecognized --release 8
# option" (set in build.gradle).
if [ ! -z "${JAVA11_HOME}" ]; then
setJava "${JAVA11_HOME}"
fi

echo "Compiling using Java:"
java -version
echo
mvn clean install

# We ensure the generated class files are compatible with Java 8
if [ ! -z "${JAVA8_HOME}" ]; then
setJava "${JAVA8_HOME}"
fi

echo "Running tests using Java:"
java -version

if [ "${GITHUB_JOB}" == "units-java8" ]; then
java -version 2>&1 | grep -q 'openjdk version "1.8.'
MATCH=$? # 0 if the output has the match
if [ "$MATCH" != "0" ]; then
echo "Please specify JDK 8 for Java 8 tests"
exit 1
fi
fi

echo
# run tests in Java 8 with the source compiled in Java 11
mvn surefire:test
4 changes: 2 additions & 2 deletions gax-java/gax-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<artifactId>gax-bom</artifactId>
<version>2.18.2-SNAPSHOT</version><!-- {x-version-update:gax-bom:current} -->
<packaging>pom</packaging>
<name>GAX (Google Api eXtensions) for Java</name>
<description>Google Api eXtensions for Java</description>
<name>GAX (Google Api eXtensions) for Java (BOM)</name>
<description>Google Api eXtensions for Java (BOM)</description>
<url>https://github.com/googleapis/gax-java</url>
<licenses>
<license>
Expand Down
105 changes: 105 additions & 0 deletions gax-java/gax-grpc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version='1.0' encoding='UTF-8'?>
<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>

<artifactId>gax-grpc</artifactId>
<version>2.18.2-SNAPSHOT</version><!-- {x-version-update:gax-grpc:current} -->
<packaging>jar</packaging>
<name>GAX (Google Api eXtensions) for Java (gRPC)</name>
<description>Google Api eXtensions for Java (gRPC)</description>

<parent>
<groupId>com.google.api</groupId>
<artifactId>gax-parent</artifactId>
<version>2.18.2-SNAPSHOT</version><!-- {x-version-update:gax:current} -->
</parent>

<dependencies>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-credentials</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-alts</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-auth</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-googleapis</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
90 changes: 90 additions & 0 deletions gax-java/gax-httpjson/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version='1.0' encoding='UTF-8'?>
<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>

<artifactId>gax-httpjson</artifactId>
<version>0.103.2-SNAPSHOT</version> <!-- {x-version-update:gax-httpjson:current} -->
<packaging>jar</packaging>
<name>GAX (Google Api eXtensions) for Java (HTTP JSON)</name>
<description>Google Api eXtensions for Java (HTTP JSON)</description>

<parent>
<groupId>com.google.api</groupId>
<artifactId>gax-parent</artifactId>
<version>2.18.2-SNAPSHOT</version><!-- {x-version-update:gax:current} -->
</parent>

<properties>
<!-- Skip breaking changes checking against previous version while gax-httpjson is not GA -->
<clirr.skip>true</clirr.skip>
</properties>

<dependencies>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-credentials</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
10 changes: 3 additions & 7 deletions gax-java/gax/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ dependencies {
shadowNoGuava libraries['maven.com_google_guava_guava']
}

ext.generatedOutputDir = file("${buildDir}/generated-resources")
task generateProjectProperties {
ext.outputFile = file("${generatedOutputDir}/dependencies.properties")
outputs.file(outputFile)
doLast {
outputFile.text = "version.gax=${project.version}"
processResources {
filesMatching('dependencies.properties') {
expand('project': project)
}
}
sourceSets.main.output.dir generatedOutputDir, builtBy: generateProjectProperties

jar {
manifest {
Expand Down
Loading

0 comments on commit ad1a767

Please sign in to comment.