Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add new Bazel workflow to docs #338

Merged
merged 3 commits into from
Sep 26, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 45 additions & 18 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,60 @@ below are temporary and better ones will be coming.
1. Clone [googleapis](https://github.com/googleapis/googleapis) and
[gapic-showcase](https://github.com/googleapis/gapic-showcase/) and install
protoc.

2. Copy the protos from Showcase into googleapis/google/showcase.

```sh
cp gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp -r gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta1


3. Export tool paths.

```sh
PROTOC_INCLUDE_DIR=/usr/local/include/google/protobuf/
GOOGLEAPIS_DIR=/usr/local/google/home/$USER/dev/googleapis
YOUR_PROTO_DIR=/usr/local/google/home/$USER/dev/googleapis/google/showcase/v1beta
3. Add the new microgenerator rules to the protobuf directory's `BUILD.bazel` file
as follows:

```python
load(
"@com_google_googleapis_imports//:imports.bzl",
# Existing rules here.
# The left-side name is simply an alias, we can use anything here.
java_microgen_gapic_assembly_gradle_pkg = "java_microgenerator_gapic_assembly_gradle_pkg",
java_microgen_gapic_library = "java_microgenerator_gapic_library",
java_microgen_gapic_test = "java_microgenerator_gapic_test",
)

# This should either replace the existing monolith target or have a unique name
# that includes "java_gapic".
java_microgen_gapic_library(
name = "showcase_java_gapic",
srcs = [":showcase_proto_with_info"],
# The gapic_yaml file is needed only for APIs that have batching configs.
gapic_yaml = "showcase_gapic.yaml",
grpc_service_config = "showcase_grpc_service_config.json",
package = "google.showcase.v1beta1",
service_yaml = "showcase.yaml",
test_deps = [
":showcase_java_grpc",
],
deps = [
":showcase_java_proto",
],
)

java_microgen_gapic_assembly_gradle_pkg(
name = "google-cloud-showcase-v1beta1-java-microgen",
deps = [
# This is the new microgen target above.
":showcase_java_gapic",
# The following targets already exist.
":showcase_java_grpc",
":showcase_java_proto",
":showcase_proto",
],
)
```

4. Build this plugin.
4. Build the new target.

```sh
bazel build :protoc-gen-java_gapic
```

5. Run the plugin. At this stage, it will not do anything except write
hardcoded Java into two files.

```
protoc -I=${PROTOC_INCLUDE_DIR} -I=${GOOGLEAPIS_DIR} -I=${YOUR_PROTO_DIR} \
--plugin=bazel-bin/protoc-gen-java_gapic ~/dev/googleapis/google/showcase/v1test/*.proto \
--gapic-java_out=/tmp/test
bazel build google/showcase/v1beta1:showcase_java_gapic
```

## Code Formatting
Expand Down