|
| 1 | +# Gemini CLI Context for sdk-platform-java |
| 2 | + |
| 3 | +## 1. Overview |
| 4 | + |
| 5 | +This directory, `sdk-platform-java`, contains the foundational components for building Java client libraries for Google Cloud Platform services. It includes the GAPIC (Generated API Client) generator for Java, the GAX (Google API Extensions) runtime library, and other shared modules. |
| 6 | + |
| 7 | +For general project rules, style guides, dependency management, and contribution guidelines, please refer to the root [AGENTS.md](../AGENTS.md). |
| 8 | + |
| 9 | +## 2. Project Structure |
| 10 | + |
| 11 | +The repository is structured into several key modules: |
| 12 | + |
| 13 | +* **`gapic-generator-java`**: The core component for creating new client libraries. It is a Protobuf compiler plugin that generates Java client libraries from API definition files. The `DEVELOPMENT.md` file in this module provides detailed information on how to work with the generator. |
| 14 | + |
| 15 | +* **`gax-java`**: The Google API Extensions for Java (GAX) library. It provides runtime support for the generated client libraries, including features like pagination, request batching, and polling of long-running operations. It has the following submodules: |
| 16 | + * `gax`: Transport-independent part of GAX for Java. |
| 17 | + * `gax-grpc`: gRPC-specific logic for GAX. |
| 18 | + * `gax-httpjson`: REST-specific logic for GAX. |
| 19 | + |
| 20 | +* **`api-common-java`**: Contains foundational types and utilities related to Google APIs. It includes the following packages: |
| 21 | + * `core`: Core library containing API stability annotations and wrappers around Guava types. |
| 22 | + * `pathtemplate`: Path Template library for manipulating strings that are formatted as Google API resource names. |
| 23 | + * `resourcenames`: Resource Name library used by generated resource name types. |
| 24 | + |
| 25 | +* **`java-common-protos`**: Provides Protobuf-generated classes for common Google services that are used across multiple APIs. The code is in this module is auto-generated and should not be modified. |
| 26 | + |
| 27 | +* **`java-iam`**: Contains Protobuf-generated classes for Google's Identity and Access Management (IAM) service, used for managing policies. The code is in this module is auto-generated and should not be modified. |
| 28 | + |
| 29 | +* **`java-showcase`**: A demonstration client library for the "Showcase" API, which is a fake API used for integration testing of the GAPIC generator and GAX library. |
| 30 | + |
| 31 | +* **`java-shared-dependencies`**: Manages shared Maven dependencies for all Google Cloud Java client libraries. This ensures consistency and helps avoid dependency conflicts. |
| 32 | + |
| 33 | +## 3. Testing |
| 34 | + |
| 35 | +For detailed testing strategy and heuristics on which tests to run based on code changes, please refer to [DEVELOPMENT.md](DEVELOPMENT.md). |
| 36 | + |
| 37 | +### 3.1. Running Unit Tests |
| 38 | + |
| 39 | +Unit tests can be tested via this command: |
| 40 | + |
| 41 | +```sh |
| 42 | +mvn test |
| 43 | +``` |
| 44 | + |
| 45 | +### 3.2. Running Golden Integration Tests |
| 46 | + |
| 47 | +Golden integration tests are run using Bazel. To run all golden integration tests, use the following command from the root of the repository: |
| 48 | + |
| 49 | +```sh |
| 50 | +bazelisk test //... |
| 51 | +``` |
| 52 | + |
| 53 | +### 3.3. Running Showcase Integration Tests |
| 54 | + |
| 55 | +```sh |
| 56 | +bazelisk test //test/integration:redis |
| 57 | +``` |
| 58 | + |
| 59 | +### 3.4. Updating Golden Files |
| 60 | + |
| 61 | +If you make changes that affect the generated code, you will need to update the golden files. This can be done using the following command: |
| 62 | + |
| 63 | +```sh |
| 64 | +bazelisk run //test/integration:update_asset && bazelisk run //test/integration:update_credentials && bazelisk run //test/integration:update_iam && bazelisk run //test/integration:update_kms && bazelisk run //test/integration:update_pubsub && bazelisk run //test/integration:update_logging && bazelisk run //test/integration:update_redis && bazelisk run //test/integration:update_storage && bazelisk run //test/integration:update_library && bazelisk run //test/integration:update_compute && bazelisk run //test/integration:update_bigtable && bazelisk run //test/integration:update_apigeeconnect |
| 65 | +``` |
| 66 | + |
| 67 | +### 3.5. Running Showcase Integration Tests |
| 68 | + |
| 69 | +Showcase integration tests are run against a local server that implements the Showcase API. The `java-showcase/README.md` file provides detailed instructions on how to run these tests. The general steps are: |
| 70 | + |
| 71 | +1. **Install the Showcase server:** |
| 72 | + |
| 73 | + ```sh |
| 74 | + go install github.com/googleapis/gapic-showcase/cmd/gapic-showcase@latest |
| 75 | + ``` |
| 76 | + |
| 77 | +2. **Run the Showcase server:** |
| 78 | + |
| 79 | + ```sh |
| 80 | + gapic-showcase run |
| 81 | + ``` |
| 82 | + |
| 83 | +3. **Run the integration tests:** |
| 84 | + |
| 85 | + ```sh |
| 86 | + cd java-showcase |
| 87 | + mvn verify -P enable-integration-tests |
| 88 | + ``` |
| 89 | + |
| 90 | +## 4. File Exclusions & Loading Constraints |
| 91 | + |
| 92 | +To maintain a highly focused context window and prevent memory overload: |
| 93 | + |
| 94 | +* **Permanent Exclusions (Always Ignore):** |
| 95 | + * Do **NOT** load, read, or search through files under the directories `java-showcase-3.21.0/` and `java-showcase-3.25.8/`. Treat these folders as completely out of scope. |
| 96 | +* **Conditional Exclusions (Ignore by Default):** |
| 97 | + * By default, do **NOT** load, read, or search through files in the `test/` folder (which contains massive auto-generated integration golden files). |
| 98 | + * **Exceptions:** You are only authorized to load or modify files under `test/` when: |
| 99 | + 1. The user explicitly asks you to *"update the golden files"* or *"inspect test files"*. |
| 100 | + 2. You are actively executing the Golden Integration Update commands (e.g. `bazelisk run //test/integration:update_...`). |
0 commit comments