Skip to content

Commit d935654

Browse files
authored
chore: move googleapis dependency to WORKSPACE and update docs (#998)
1 parent e8ea769 commit d935654

File tree

4 files changed

+89
-84
lines changed

4 files changed

+89
-84
lines changed

DEVELOPMENT.md

+73-73
Original file line numberDiff line numberDiff line change
@@ -12,79 +12,6 @@
1212
cp .githooks/pre-commit .git/hooks/pre-commit
1313
```
1414

15-
## Running the Plugin
16-
17-
1. Clone [googleapis](https://github.com/googleapis/googleapis) and
18-
[gapic-showcase](https://github.com/googleapis/gapic-showcase/).
19-
20-
2. Copy the protos from Showcase into googleapis/google/showcase.
21-
22-
```sh
23-
mkdir googleapis/google/showcase
24-
cp -r gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta1
25-
```
26-
27-
3. Add the new microgenerator rules to
28-
`googleapis/google/showcase/v1beta1/BUILD.bazel` file as follows:
29-
30-
```python
31-
load(
32-
"@com_google_googleapis_imports//:imports.bzl",
33-
# Existing rules here.
34-
"java_gapic_assembly_gradle_pkg",
35-
"java_gapic_library",
36-
"java_proto_library",
37-
"proto_library_with_info",
38-
)
39-
40-
proto_library_with_info(
41-
name = "showcase_proto_with_info",
42-
deps = [
43-
":showcase_proto",
44-
],
45-
)
46-
47-
java_proto_library(
48-
name = "showcase_java_proto",
49-
deps = [
50-
":showcase_proto",
51-
],
52-
)
53-
54-
# This should either replace the existing monolith target or have a unique name
55-
# that includes "java_gapic".
56-
java_gapic_library(
57-
name = "showcase_java_gapic",
58-
srcs = [":showcase_proto_with_info"],
59-
grpc_service_config = "showcase_grpc_service_config.json",
60-
test_deps = [
61-
":showcase_java_grpc",
62-
],
63-
deps = [
64-
":showcase_java_proto",
65-
],
66-
)
67-
68-
java_gapic_assembly_gradle_pkg(
69-
# This name should be unique from the existing target name.
70-
name = "google-cloud-showcase-v1beta1-java",
71-
deps = [
72-
# This is the new microgen target above.
73-
":showcase_java_gapic",
74-
# The following targets already exist.
75-
":showcase_java_grpc",
76-
":showcase_java_proto",
77-
":showcase_proto",
78-
],
79-
)
80-
```
81-
82-
4. Build the new target.
83-
84-
```sh
85-
bazel build //google/showcase/v1beta1:showcase_java_gapic
86-
```
87-
8815
## Code Formatting
8916

9017
- Run linter checks without actually doing the formatting.
@@ -167,3 +94,76 @@
16794
```sh
16895
bazel run //test/integration:update_redis
16996
```
97+
98+
## Running the Plugin
99+
100+
1. Clone [googleapis](https://github.com/googleapis/googleapis) and
101+
[gapic-showcase](https://github.com/googleapis/gapic-showcase/).
102+
103+
2. Copy the protos from Showcase into googleapis/google/showcase.
104+
105+
```sh
106+
mkdir googleapis/google/showcase
107+
cp -r gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta1
108+
```
109+
110+
3. Add the new microgenerator rules to
111+
`googleapis/google/showcase/v1beta1/BUILD.bazel` file as follows:
112+
113+
```python
114+
load(
115+
"@com_google_googleapis_imports//:imports.bzl",
116+
# Existing rules here.
117+
"java_gapic_assembly_gradle_pkg",
118+
"java_gapic_library",
119+
"java_proto_library",
120+
"proto_library_with_info",
121+
)
122+
123+
proto_library_with_info(
124+
name = "showcase_proto_with_info",
125+
deps = [
126+
":showcase_proto",
127+
],
128+
)
129+
130+
java_proto_library(
131+
name = "showcase_java_proto",
132+
deps = [
133+
":showcase_proto",
134+
],
135+
)
136+
137+
# This should either replace the existing monolith target or have a unique name
138+
# that includes "java_gapic".
139+
java_gapic_library(
140+
name = "showcase_java_gapic",
141+
srcs = [":showcase_proto_with_info"],
142+
grpc_service_config = "showcase_grpc_service_config.json",
143+
test_deps = [
144+
":showcase_java_grpc",
145+
],
146+
deps = [
147+
":showcase_java_proto",
148+
],
149+
)
150+
151+
java_gapic_assembly_gradle_pkg(
152+
# This name should be unique from the existing target name.
153+
name = "google-cloud-showcase-v1beta1-java",
154+
deps = [
155+
# This is the new microgen target above.
156+
":showcase_java_gapic",
157+
# The following targets already exist.
158+
":showcase_java_grpc",
159+
":showcase_java_proto",
160+
":showcase_proto",
161+
],
162+
)
163+
```
164+
165+
4. Build the new target.
166+
167+
```sh
168+
bazel build //google/showcase/v1beta1:showcase_java_gapic
169+
```

WORKSPACE

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ load("@com_google_api_gax_java//:repositories.bzl", "com_google_api_gax_java_rep
5252

5353
com_google_api_gax_java_repositories()
5454

55+
http_archive(
56+
name = "com_google_googleapis",
57+
strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c",
58+
urls = [
59+
"https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip",
60+
],
61+
)
62+
5563
load("//:repositories.bzl", "gapic_generator_java_repositories")
5664

5765
gapic_generator_java_repositories()

repositories.bzl

-9
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ def gapic_generator_java_repositories():
5656
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
5757
)
5858

59-
_maybe(
60-
http_archive,
61-
name = "com_google_googleapis",
62-
strip_prefix = "googleapis-44d6bef0ca6db8bba3fb324c8186e694bcc4829c",
63-
urls = [
64-
"https://github.com/googleapis/googleapis/archive/44d6bef0ca6db8bba3fb324c8186e694bcc4829c.zip",
65-
],
66-
)
67-
6859
_maybe(
6960
native.bind,
7061
name = "guava",

test/integration/goldens/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Goldens Files For Integration Test
22

33
This folder contains goldens files that are expected to be generated from Java Microgenerator
4-
against differenct APIs. For example `redis` folder has all the Java source files in the generated
4+
against different APIs. For example `redis` folder has all the Java source files in the generated
55
Redis client library. They are all actual Java files, but used as goldens.
66

77
## Purpose
@@ -20,5 +20,11 @@ If the actual generated Java source files are not identical with the goldens fil
2020
update the goldens using source files. Run the command below to overwrite the goldens files in `redis` folder.
2121

2222
```sh
23-
bazel run //test/integration:redis_update
23+
bazel run //test/integration:update_redis
2424
```
25+
26+
## Adding new integration tests
27+
28+
If you are adding a new API for integration testing, be sure to add it in the `BUILD.bazel` under the `Integration Test Rules` and add the `java_gapic_test` rules for the new API under the `API Library Rules` section.
29+
30+
You need to manually create a new directory for your new API under the `test/integration/goldens` with the same name you've used for the `Integration Test Rules`. Then when you run the command to update goldens (above), it will automatically create the goldens needed.

0 commit comments

Comments
 (0)