diff --git a/.github/workflows/ci-maven.yaml b/.github/workflows/ci-maven.yaml new file mode 100644 index 0000000000..5ffc8cae1b --- /dev/null +++ b/.github/workflows/ci-maven.yaml @@ -0,0 +1,34 @@ +on: + push: + branches: + - main + pull_request: +name: ci-maven +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + java: [8, 11] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - run: java -version + + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Unit Tests + run: | + mvn verify --batch-mode --no-transfer-progress + + - name: Java Linter + run: mvn fmt:check diff --git a/.gitignore b/.gitignore index a484993351..913a2a8e6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -# Bazel. bazel-* .gradle/ +target/ # IDE .idea diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 229f780447..856fea7d6e 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -92,12 +92,20 @@ ```sh bazel run //:google_java_format_verification ``` + or + ```sh + mvn fmt:check + ``` - Format files. ```sh bazel run //:google_java_format ``` + or + ```sh + mvn fmt:format + ``` ## Test Running @@ -112,18 +120,38 @@ ```sh bazel test //:units ``` + or + ```sh + mvn test + ``` -- Run a single unit test like `JavaCodeGeneratorTest.java` +- Run a single unit test like `JavaCodeGeneratorTest.java`: ```sh bazel test //:unit_com_google_api_generator_engine_JavaCodeGeneratorTest ``` + or + ```sh + mvn test -Dtest=JavaCodeGeneratorTest + + mvn test "-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]" + ``` + +- Update all unit test golden files: -- Update unit test golden files, for example `JavaCodeGeneratorTest.java`: + ```sh + mvn test -DupdateUnitGoldens + ``` + +- Update a single unit test golden file, for example `JavaCodeGeneratorTest.java`: ```sh bazel run //:update_com_google_api_generator_engine_JavaCodeGeneratorTest ``` + or + ```sh + mvn test -DupdateUnitGoldens -Dtest=JavaCodeGeneratorTest + ``` - Run a single integration test for API like `Redis`, it generates Java source code using the Java microgenerator and compares them with the goldens files diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000..e7f28f51fe --- /dev/null +++ b/pom.xml @@ -0,0 +1,328 @@ + + 4.0.0 + com.google.api + gapic-generator-java + 0.0.1-SNAPSHOT + + + UTF-8 + + 44d6bef0ca6db8bba3fb324c8186e694bcc4829c + + + + + + com.google.cloud + google-cloud-shared-dependencies + 2.7.0 + pom + import + + + + + + + + kr.motd.maven + os-maven-plugin + 1.7.0 + + + + + + maven-compiler-plugin + 3.8.1 + + 8 + 8 + + + com.google.auto.value + auto-value + 1.7.2 + + + + + + + com.coveo + fmt-maven-plugin + 2.9.1 + + + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.6.8 + + + download-metadata-proto + generate-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/gapic/metadata/gapic_metadata.proto + ${project.build.directory}/generated-sources/proto/ + + + + download-common-resources-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/cloud/common_resources.proto + ${project.build.directory}/generated-test-sources/proto/ + + + + download-pubsub-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/pubsub/v1/pubsub.proto + ${project.build.directory}/generated-test-sources/proto/ + + + + download-schema-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/pubsub/v1/schema.proto + ${project.build.directory}/generated-test-sources/proto/google/pubsub/v1/ + + + + download-logging-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging.proto + ${project.build.directory}/generated-test-sources/proto/ + + + + download-log-entry-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/log_entry.proto + ${project.build.directory}/generated-test-sources/proto/google/logging/v2/ + + + + download-logging-config-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging_config.proto + ${project.build.directory}/generated-test-sources/proto/google/logging/v2/ + + + + download-logging-metrics-proto + generate-test-sources + + wget + + + https://raw.githubusercontent.com/googleapis/googleapis/${googleapis.commit}/google/logging/v2/logging_metrics.proto + ${project.build.directory}/generated-test-sources/proto/google/logging/v2/ + + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + com.google.protobuf:protoc:3.19.4:exe:${os.detected.classifier} + + + + compile-protos + + compile + + + + compile-downloaded-protos + + compile + + + ${project.build.directory}/generated-sources/proto/ + false + + + + compile-test-protos + + test-compile + + + true + true + true + test-proto.descriptorset + + + + compile-downloaded-test-protos + + test-compile + + + ${project.build.directory}/generated-test-sources/proto/ + false + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + ${project.build.directory}/generated-test-resources/protobuf/descriptor-sets/ + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.api + gax + testlib + + + com.google.api + gax-grpc + + + com.google.api + gax-grpc + testlib + + + com.google.api + gax-httpjson + + + com.google.api + gax-httpjson + testlib + + + com.google.auto.value + auto-value-annotations + + + com.google.protobuf + protobuf-java-util + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + org.yaml + snakeyaml + 1.26 + + + com.google.googlejavaformat + google-java-format + 1.7 + + + junit + junit + 4.13.1 + + + + + javax.annotation + javax.annotation-api + + + + com.google.truth + truth + 1.1.2 + test + + + io.github.java-diff-utils + java-diff-utils + 4.0 + test + + +