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

doc: Update DEVELOPMENT.md for local development. #1237

Merged
merged 22 commits into from
Feb 1, 2023
Merged
Changes from 3 commits
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
70 changes: 49 additions & 21 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ $ cd showcase
$ mvn compile -P update
```

## Running the Plugin
## Running the Plugin under googleapis with local gapic-generator-java

See also above section "Showcase Integration Testing".
blakeli0 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -171,28 +171,52 @@ To generate a production GAPIC API:
2. Point to local gapic-generator-java
lqiu96 marked this conversation as resolved.
Show resolved Hide resolved

Normally, googleapis's build pulls in googleapis/gapic-generator-java from the
Internet:

```
# Java microgenerator.
_gapic_generator_java_version = "2.1.0"
Internet, we need to build a local SNAPSHOT jar first and point googleapis to the SNAPSHOT jar and local copy of the repo.
lqiu96 marked this conversation as resolved.
Show resolved Hide resolved

http_archive(
name = "gapic_generator_java",
urls = ["https://github.com/googleapis/gapic-generator-java/archive/v%s.zip" % _gapic_generator_java_version],
)
Before:
```
_gapic_generator_java_version = "2.13.0"

maven_install(
artifacts = [
"com.google.api:gapic-generator-java:" + _gapic_generator_java_version,
],
#Update this False for local development
fail_on_missing_checksum = True,
repositories = [
"m2Local",
"https://repo.maven.apache.org/maven2/",
]
)

http_archive(
name = "gapic_generator_java",
strip_prefix = "gapic-generator-java-%s" % _gapic_generator_java_version,
urls = ["https://github.com/googleapis/gapic-generator-java/archive/v%s.zip" % _gapic_generator_java_version],
)
```

By replacing this portion using the built-in local_repository rule, you can make
it refer to your local development repo:
After

```
local_repository(
name = "gapic_generator_java",
path = "/home/<your id>/gapic-generator-java",
)
_gapic_generator_java_version = "2.13.1-SNAPSHOT"

maven_install(
lqiu96 marked this conversation as resolved.
Show resolved Hide resolved
artifacts = [
"com.google.api:gapic-generator-java:" + _gapic_generator_java_version,
],
#Update this False for local development
fail_on_missing_checksum = False,
Copy link
Member

Choose a reason for hiding this comment

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

(I'm Bazel novice) Can't this True/False be a variable, based on _gapic-generator_java_version has SNAPSHOT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's doable as Bazel scripts are basically a Python variant, but we may want to test non-SNAPSHOT version locally sometimes.

repositories = [
"m2Local",
"https://repo.maven.apache.org/maven2/",
]
)

local_repository(
name = "gapic_generator_java",
path = "/absolute/path/to/your/local/gapic-generator-java",
)
```

3. Build the new target.
Expand All @@ -206,6 +230,10 @@ To generate a production GAPIC API:
```
bazel build //google/cloud/speech/v2:google-cloud-speech-v2-java
```




Note: If you are running into bazel build issues, you can try to remove gapic-generator-java cached in your local m2
lqiu96 marked this conversation as resolved.
Show resolved Hide resolved
Try running this command:
```
rm -rf ~/.m2/repository/com/google/api/
```
and then rebuild gapic-generator-java (`mvn clean install`).