Warning: The monolith generator has been deprecated. Please use the microgenerators instead.
The Gapic generator allows you create highly idiomatic and usable Java client libraries for One Platform APIs.
-
Clone the repo.
REPO_ROOT=~/gapic-generator git clone [email protected]:googleapis/gapic-generator.git $REPO_ROOT
-
Install Gradle. Please refer to the steps here
-
Run google-java-format.
cd $REPO_ROOT ./gradlew googleJavaFormat
-
Build the code.
./gradlew fatJar
-
Run tests.
./gradlew test
For our example, we'll use gapic-showcase.
-
Clone googleapis and gapic-showcase and install protoc.
GOOGLEAPIS=~/googleapis GAPIC_SHOWCASE=~/gapic-showcase git clone [email protected]:googleapis/googleapis.git $GOOGLEAPIS git clone [email protected]:googleapis/gapic-showcase $GAPIC_SHOWCASE
-
Copy the protos from Showcase into googleapis/google/showcase.
cp $GAPIC_SHOWCASE/schema/google/showcase/v1beta1 $GOOGLEAPIS/google/showcase/v1beta
-
Generate the Bazel build rules.
cd $GOOGLEAPIS bazel run //:build_gen -- --src=google/showcase/v1beta1
-
Call
bazel build
on the appropriate rule.bazel build google/showcase/v1beta1:showcase_java_gapic
-
To find the generated sources, build the following rule. (Replace "java" with the approrpriate language to see other languagues' generated source.)
bazel build google/showcase/v1beta1:google-cloud-showcase-v1beta1
-
To use a local copy of the GAPIC generator with changes, point the WORKSPACE directory to your local one instead. Replace the
http_archive
rule with thelocal_repository
rule below.local_repository( name = "com_google_api_codegen", path = /usr/local/google/home/{{USERNAME}}/gapic-generator )