-
Clone this repo.
-
Copy the Git pre-commit hooks. This will automatically check the build, run tests, and perform linting before each commit. (Symlinks don't seem to work, but if you find a way, please add it here!)
cp .githooks/pre-commit .git/hooks/pre-commit
-
Clone googleapis and gapic-showcase.
-
Copy the protos from Showcase into googleapis/google/showcase.
mkdir googleapis/google/showcase cp -r gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta1
-
Add the new microgenerator rules to
googleapis/google/showcase/v1beta1/BUILD.bazel
file as follows:load( "@com_google_googleapis_imports//:imports.bzl", # Existing rules here. "java_gapic_assembly_gradle_pkg", "java_gapic_library", "java_proto_library", "proto_library_with_info", ) proto_library_with_info( name = "showcase_proto_with_info", deps = [ ":showcase_proto", ], ) java_proto_library( name = "showcase_java_proto", deps = [ "showcase_proto", ], ) # This should either replace the existing monolith target or have a unique name # that includes "java_gapic". java_gapic_library( name = "showcase_java_gapic", srcs = [":showcase_proto_with_info"], grpc_service_config = "showcase_grpc_service_config.json", test_deps = [ ":showcase_java_grpc", ], deps = [ ":showcase_java_proto", ], ) java_gapic_assembly_gradle_pkg( # This name should be unique from the existing target name. name = "google-cloud-showcase-v1beta1-java", deps = [ # This is the new microgen target above. ":showcase_java_gapic", # The following targets already exist. ":showcase_java_grpc", ":showcase_java_proto", ":showcase_proto", ], )
-
Build the new target.
bazel build google/showcase/v1beta1:showcase_java_gapic
-
Run linter checks without actually doing the formatting.
bazel build :google_java_format_verification
-
Format files.
bazel run :google_java_format
-
Run all unit tests.
bazel test //...
-
Run a single unit test like
JavaCodeGeneratorTest.java
bazel run //src/test/java/com/google/api/generator/engine: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 intest/integration/goldens/redis
.bazel test //test/integration:redis
-
Run all unit and integration tests.
bazel test $(bazel query "src/test/..." | grep "Test$") //test/integration/...
-
Update unit test golden files, for example
JavaCodeGeneratorTest.java
:bazel run //src/test/java/com/google/api/generator/engine:JavaCodeGeneratorTest_update
-
Update integration test golden files, for example
Redis
. This clobbers all the files intest/integration/goldens/redis
.bazel run //test/integration:redis_update