|
| 1 | +# Agents Guide for google-cloud-java |
| 2 | + |
| 3 | +## 1. Overview |
| 4 | +This repository, `google-cloud-java`, contains the Java client libraries for Google Cloud Platform services, as well as core components in `sdk-platform-java`. |
| 5 | + |
| 6 | +## 2. Project Structure |
| 7 | +The repository is a monorepo containing both generated and handwritten libraries, as well as core platform components and parent POMs. |
| 8 | + |
| 9 | +### Core Modules |
| 10 | +- **`sdk-platform-java/`**: Contains foundational components for building client libraries. |
| 11 | + - **Note**: This directory has its own `GEMINI.md` file with detailed instructions specific to core development (GAPIC generator, GAX). |
| 12 | + - Includes `gapic-generator-java` (the generator) and `gax-java` (Google API Extensions). |
| 13 | +- **`google-auth-library-java/`**: The Google Auth Library for Java. This is a **handwritten** library used for authentication and credential management across all Google Cloud clients. It is a critical dependency for all client libraries. |
| 14 | + |
| 15 | +### Parent Modules and BOMs |
| 16 | +- **`google-cloud-pom-parent/`**: The top-level parent POM for all modules in the repository. It manages plugin versions and common configuration. |
| 17 | +- **`google-cloud-jar-parent/`**: The parent POM for all client library JAR modules in the repository. It inherits from `google-cloud-pom-parent` and manages shared dependencies. |
| 18 | +- **`gapic-libraries-bom/`**: The Bill of Materials (BOM) that manages versions of all client libraries to ensure compatibility when used together. |
| 19 | +- **`java-shared-dependencies/`** (inside `sdk-platform-java`): Manages shared Maven dependencies for all Google Cloud Java client libraries to ensure consistency and avoid conflicts. |
| 20 | + |
| 21 | +### Client Libraries (`java-<service>/`) |
| 22 | +Directories starting with `java-` are client libraries for specific Google Cloud services. |
| 23 | +- **Generated Clients**: The majority of these are automatically generated from service definitions (protos) using the GAPIC generator in `sdk-platform-java`. |
| 24 | +- **Handwritten & Split Repositories**: Some major libraries are either entirely handwritten or are maintained as "split repos" (they have their own standalone repositories in the `googleapis` GitHub organization but are also managed here). When working on these, be aware that changes may need to be synchronized with their respective split repos. Key examples include: |
| 25 | + - **BigQuery**: [java-bigquery](java-bigquery) |
| 26 | + - **BigQuery Storage**: [java-bigquerystorage](java-bigquerystorage) |
| 27 | + - **Spanner**: [java-spanner](java-spanner) |
| 28 | + - **Spanner JDBC**: [java-spanner-jdbc](java-spanner-jdbc) |
| 29 | + - **Storage**: [java-storage](java-storage) |
| 30 | + - **Storage NIO**: [java-storage-nio](java-storage-nio) |
| 31 | + - **Datastore**: [java-datastore](java-datastore) |
| 32 | + - **Logging**: [java-logging](java-logging) |
| 33 | + |
| 34 | +## 3. Getting Started |
| 35 | +### Prerequisites |
| 36 | +- Java 11+ |
| 37 | +- Maven |
| 38 | +- Bazelisk (for integration tests in `sdk-platform-java`) |
| 39 | + |
| 40 | +### Building the Project |
| 41 | +- Build all modules: `mvn install` from root. |
| 42 | +- Recommended for faster builds: `mvn install -T 1C -P quick-build`. |
| 43 | +- Build specific module: Run `mvn` commands within the module directory. |
| 44 | + |
| 45 | +### Code Formatting |
| 46 | +- Check: `mvn fmt:check` |
| 47 | +- Format: `mvn fmt:format` |
| 48 | +- Tip: Run in specific module to save time. |
| 49 | + |
| 50 | +## 4. Testing Strategy |
| 51 | +- **Unit Tests**: `mvn test`. |
| 52 | +- **Integration Tests**: Module specific, may require emulators or live services. |
| 53 | +- **Core Components Testing**: See [sdk-platform-java/DEVELOPMENT.md](sdk-platform-java/DEVELOPMENT.md) for a detailed explanation of the 4 layers of testing (Traditional Unit, Golden Unit, Showcase, Golden Integration). |
| 54 | + |
| 55 | +## 5. Style Guide |
| 56 | +1. Minimize visibility scopes. Default to most restrictive access level. |
| 57 | +2. Use short names over fully qualified names. |
| 58 | +3. Avoid calling `@ObsoleteApi` or `@Deprecated` methods. |
| 59 | +4. Avoid unnecessary formatting changes to keep diffs clean. |
| 60 | +5. Use `mvn` for everything other than the `test/integration` folder. |
| 61 | + |
| 62 | +## 6. Dependency Management |
| 63 | +- Do not bump external dependency versions unless for CVE or critical bug fix. |
| 64 | +- Avoid introducing new external dependencies. |
| 65 | +- Prefer Java standard library, then existing dependencies. |
| 66 | + |
| 67 | +## 7. Contribution Guidelines |
| 68 | +- **Commits**: Conventional Commits `<type>(<scope>): <description>`. |
| 69 | +- **Pull Requests**: Submitted via PR, require review. Pull latest from main and resolve conflicts. |
| 70 | +- **Testing**: All new logic should be accompanied by tests. |
| 71 | + |
| 72 | +## 8. Specialized Development Guides |
| 73 | +For development on core components, refer to the following guides in `sdk-platform-java`: |
| 74 | +- **GAPIC Generator**: [sdk-platform-java/gapic-generator-java/DEVELOPMENT.md](sdk-platform-java/gapic-generator-java/DEVELOPMENT.md) |
| 75 | +- **GAX**: [sdk-platform-java/gax-java/DEVELOPMENT.md](sdk-platform-java/gax-java/DEVELOPMENT.md) |
| 76 | +- **Hermetic Build**: [sdk-platform-java/hermetic_build/DEVELOPMENT.md](sdk-platform-java/hermetic_build/DEVELOPMENT.md) |
0 commit comments