From ad1a767f8fe3af4965d8f03ec85cddbcca550dcc Mon Sep 17 00:00:00 2001 From: Mike Eltsufin Date: Thu, 9 Jun 2022 14:17:28 -0400 Subject: [PATCH] chore: Add Maven build (#1562) Co-authored-by: Blake Li --- gax-java/.github/workflows/ci.yaml | 19 ++ gax-java/.gitignore | 3 +- gax-java/.kokoro/maven-build.sh | 61 +++++ gax-java/gax-bom/pom.xml | 4 +- gax-java/gax-grpc/pom.xml | 105 ++++++++ gax-java/gax-httpjson/pom.xml | 90 +++++++ gax-java/gax/build.gradle | 10 +- gax-java/gax/pom.xml | 83 +++++++ .../main/resources/dependencies.properties | 2 + gax-java/java.header | 29 +++ gax-java/license-checks.xml | 10 + gax-java/pom.xml | 235 ++++++++++++++++++ 12 files changed, 640 insertions(+), 11 deletions(-) create mode 100755 gax-java/.kokoro/maven-build.sh create mode 100644 gax-java/gax-grpc/pom.xml create mode 100644 gax-java/gax-httpjson/pom.xml create mode 100644 gax-java/gax/pom.xml create mode 100644 gax-java/gax/src/main/resources/dependencies.properties create mode 100644 gax-java/java.header create mode 100644 gax-java/license-checks.xml create mode 100644 gax-java/pom.xml diff --git a/gax-java/.github/workflows/ci.yaml b/gax-java/.github/workflows/ci.yaml index 249574f052..29ccc4023c 100644 --- a/gax-java/.github/workflows/ci.yaml +++ b/gax-java/.github/workflows/ci.yaml @@ -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 diff --git a/gax-java/.gitignore b/gax-java/.gitignore index 5687543f87..e6010998cb 100644 --- a/gax-java/.gitignore +++ b/gax-java/.gitignore @@ -4,6 +4,7 @@ build .gradle tmp_docs bazel-* +target # Eclipse .apt_generated* @@ -21,5 +22,3 @@ out *.sw* *.vim -# Auto-generated files. -gax/src/main/resources/dependencies.properties diff --git a/gax-java/.kokoro/maven-build.sh b/gax-java/.kokoro/maven-build.sh new file mode 100755 index 0000000000..6963f8ac6d --- /dev/null +++ b/gax-java/.kokoro/maven-build.sh @@ -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 diff --git a/gax-java/gax-bom/pom.xml b/gax-java/gax-bom/pom.xml index 0e56218945..fa15b7416f 100644 --- a/gax-java/gax-bom/pom.xml +++ b/gax-java/gax-bom/pom.xml @@ -5,8 +5,8 @@ gax-bom 2.18.2-SNAPSHOT pom - GAX (Google Api eXtensions) for Java - Google Api eXtensions for Java + GAX (Google Api eXtensions) for Java (BOM) + Google Api eXtensions for Java (BOM) https://github.com/googleapis/gax-java diff --git a/gax-java/gax-grpc/pom.xml b/gax-java/gax-grpc/pom.xml new file mode 100644 index 0000000000..b418a8d50f --- /dev/null +++ b/gax-java/gax-grpc/pom.xml @@ -0,0 +1,105 @@ + + + 4.0.0 + + gax-grpc + 2.18.2-SNAPSHOT + jar + GAX (Google Api eXtensions) for Java (gRPC) + Google Api eXtensions for Java (gRPC) + + + com.google.api + gax-parent + 2.18.2-SNAPSHOT + + + + + com.google.api + gax + + + com.google.api + api-common + + + com.google.api.grpc + proto-google-common-protos + + + com.google.auth + google-auth-library-credentials + + + com.google.guava + guava + + + io.grpc + grpc-api + + + org.threeten + threetenbp + + + com.google.auth + google-auth-library-oauth2-http + + + io.grpc + grpc-alts + + + io.grpc + grpc-auth + + + io.grpc + grpc-protobuf + + + io.grpc + grpc-stub + + + io.grpc + grpc-netty-shaded + runtime + + + io.grpc + grpc-googleapis + runtime + + + com.google.code.findbugs + jsr305 + provided + + + org.graalvm.sdk + graal-sdk + provided + + + com.google.auto.value + auto-value-annotations + provided + + + + + com.google.api.grpc + grpc-google-common-protos + test + + + com.google.api + gax + test-jar + test + + + \ No newline at end of file diff --git a/gax-java/gax-httpjson/pom.xml b/gax-java/gax-httpjson/pom.xml new file mode 100644 index 0000000000..4af49e46b5 --- /dev/null +++ b/gax-java/gax-httpjson/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + gax-httpjson + 0.103.2-SNAPSHOT + jar + GAX (Google Api eXtensions) for Java (HTTP JSON) + Google Api eXtensions for Java (HTTP JSON) + + + com.google.api + gax-parent + 2.18.2-SNAPSHOT + + + + + true + + + + + com.google.api + gax + + + com.google.api + api-common + + + com.google.api.grpc + proto-google-common-protos + + + com.google.auth + google-auth-library-credentials + + + com.google.code.gson + gson + + + com.google.guava + guava + + + com.google.http-client + google-http-client + + + com.google.protobuf + protobuf-java + + + org.threeten + threetenbp + + + com.google.auth + google-auth-library-oauth2-http + + + com.google.http-client + google-http-client-gson + + + com.google.protobuf + protobuf-java-util + + + com.google.code.findbugs + jsr305 + provided + + + com.google.auto.value + auto-value-annotations + provided + + + + + com.google.api + gax + test-jar + test + + + \ No newline at end of file diff --git a/gax-java/gax/build.gradle b/gax-java/gax/build.gradle index 43aa01875c..09a892d799 100644 --- a/gax-java/gax/build.gradle +++ b/gax-java/gax/build.gradle @@ -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 { diff --git a/gax-java/gax/pom.xml b/gax-java/gax/pom.xml new file mode 100644 index 0000000000..8c68522b32 --- /dev/null +++ b/gax-java/gax/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + gax + 2.18.2-SNAPSHOT + jar + GAX (Google Api eXtensions) for Java (Core) + Google Api eXtensions for Java (Core) + + + com.google.api + gax-parent + 2.18.2-SNAPSHOT + + + + + com.google.api + api-common + + + com.google.auth + google-auth-library-credentials + + + com.google.api.grpc + proto-google-common-protos + + + com.google.protobuf + protobuf-java + + + org.threeten + threetenbp + + + io.opencensus + opencensus-api + + + com.google.guava + guava + + + com.google.auth + google-auth-library-oauth2-http + + + com.google.code.findbugs + jsr305 + provided + + + org.graalvm.sdk + graal-sdk + provided + + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + \ No newline at end of file diff --git a/gax-java/gax/src/main/resources/dependencies.properties b/gax-java/gax/src/main/resources/dependencies.properties new file mode 100644 index 0000000000..60e15975f8 --- /dev/null +++ b/gax-java/gax/src/main/resources/dependencies.properties @@ -0,0 +1,2 @@ +# Used in GaxProperties to determine the version of the project +version.gax=${project.version} \ No newline at end of file diff --git a/gax-java/java.header b/gax-java/java.header new file mode 100644 index 0000000000..0ae9545dbb --- /dev/null +++ b/gax-java/java.header @@ -0,0 +1,29 @@ +^/\*$ +^ \* Copyright 20\d\d Google LLC$ +^ \*$ +^ \* Redistribution and use in source and binary forms, with or without$ +^ \* modification, are permitted provided that the following conditions are$ +^ \* met:$ +^ \*$ +^ \* \* Redistributions of source code must retain the above copyright$ +^ \* notice, this list of conditions and the following disclaimer.$ +^ \* \* Redistributions in binary form must reproduce the above$ +^ \* copyright notice, this list of conditions and the following disclaimer$ +^ \* in the documentation and/or other materials provided with the$ +^ \* distribution.$ +^ \* \* Neither the name of Google LLC nor the names of its$ +^ \* contributors may be used to endorse or promote products derived from$ +^ \* this software without specific prior written permission.$ +^ \*$ +^ \* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS$ +^ \* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT$ +^ \* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR$ +^ \* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT$ +^ \* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,$ +^ \* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING, BUT NOT$ +^ \* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,$ +^ \* DATA, OR PROFITS; OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON ANY$ +^ \* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT$ +^ \* \(INCLUDING NEGLIGENCE OR OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE$ +^ \* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.$ +^ \*/$ \ No newline at end of file diff --git a/gax-java/license-checks.xml b/gax-java/license-checks.xml new file mode 100644 index 0000000000..362833222e --- /dev/null +++ b/gax-java/license-checks.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/gax-java/pom.xml b/gax-java/pom.xml new file mode 100644 index 0000000000..ef2b77be18 --- /dev/null +++ b/gax-java/pom.xml @@ -0,0 +1,235 @@ + + + 4.0.0 + com.google.api + gax-parent + pom + 2.18.2-SNAPSHOT + GAX (Google Api eXtensions) for Java (Parent) + https://github.com/googleapis/gax-java + Google Api eXtensions for Java (Parent) + + + com.google.cloud + google-cloud-shared-config + 1.4.0 + + + + + GoogleAPIs + GoogleAPIs + googleapis@googlegroups.com + Google LLC + https://www.google.com + + + + + scm:git:https://github.com/googleapis/gax-java.git + https://github.com/googleapis/gax-java + + + + + BSD + https://github.com/googleapis/gax-java/blob/master/LICENSE + + + + + UTF-8 + 1.8 + 1.8 + 1.9 + + + + gax + gax-grpc + gax-httpjson + gax-bom + + + + + + com.google.api + api-common + 2.1.5 + + + com.google.auth + google-auth-library-credentials + 1.6.0 + + + org.threeten + threetenbp + 1.5.0 + + + com.google.auth + google-auth-library-oauth2-http + 1.6.0 + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.google.guava + guava + 31.1-jre + + + io.opencensus + opencensus-api + 0.31.0 + + + com.google.auto.value + auto-value-annotations + ${auto-value.version} + + + com.google.auto.value + auto-value + ${auto-value.version} + + + junit + junit + 4.13.2 + + + org.mockito + mockito-core + 4.0.0 + + + com.google.api + gax + 2.18.2-SNAPSHOT + + + com.google.api + gax + 2.18.2-SNAPSHOT + test-jar + + + com.google.api.grpc + proto-google-common-protos + 2.8.3 + + + com.google.api.grpc + grpc-google-common-protos + 2.8.3 + + + io.grpc + grpc-bom + 1.45.1 + pom + import + + + com.google.code.gson + gson + 2.9.0 + + + org.graalvm.sdk + graal-sdk + 22.1.0 + + + com.google.http-client + google-http-client-bom + 1.41.5 + pom + import + + + com.google.protobuf + protobuf-bom + 3.19.4 + pom + import + + + + + + + + junit + junit + test + + + org.mockito + mockito-core + test + + + com.google.truth + truth + 1.1.3 + + + org.checkerframework + checker-qual + + + com.google.errorprone + error_prone_annotations + + + test + + + + + + + maven-compiler-plugin + + + + com.google.auto.value + auto-value + ${auto-value.version} + + + 8 + + + + org.apache.maven.plugins + maven-jar-plugin + + + false + false + + + + + com.coveo + fmt-maven-plugin + + + validate + + check + + + + + + + \ No newline at end of file