-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs: add root-level development.md guide for scoped builds #13151
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||
| # Monorepo Scoped Development Guide | ||||||
|
|
||||||
| This document outlines highly efficient development workflows and build strategies when working with specific client libraries or modules in the `google-cloud-java` monorepo. | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## 1. Building a Specific Service (Fast Reactor Builds) | ||||||
|
|
||||||
| Instead of running a full build of the entire monorepo (which contains over 250+ modules and can take up to 30 minutes), you can target a single client library and let Maven automatically resolve and build all of its upstream dependencies using the `-pl` (project list) and `-am` (also make) flags. | ||||||
|
|
||||||
| Run the following command from the **root directory** of the repository: | ||||||
|
|
||||||
| ```bash | ||||||
| mvn compile -pl java-spanner/google-cloud-spanner -am -P quick-build -DskipTests | ||||||
| ``` | ||||||
|
|
||||||
| ### Flag Explanations: | ||||||
| * **`-pl <module-path>`**: Targets only the specified project module. | ||||||
| * **`-am` (Also Make)**: Tells Maven to analyze the dependency tree and automatically compile any projects in the reactor that the target library depends on (e.g., `gax-java`, `google-auth-library-java`, `google-cloud-core`). | ||||||
| * **`-P quick-build`**: Bypasses unnecessary verification checks (like Checkstyle, Enforcer, Animal Sniffer) to significantly speed up local iteration. | ||||||
| * **`-DskipTests`**: Skips running unit and integration tests during compilation. | ||||||
|
|
||||||
| ### Edge Case: Imported BOMs in `<dependencyManagement>` | ||||||
|
|
||||||
| > [!WARNING] | ||||||
| > **Maven's `-am` (Also Make) reactor analysis does not automatically build imported BOMs.** | ||||||
|
|
||||||
| #### The Problem: | ||||||
| If a module (or one of its parent dependencies/dependency BOMs) imports another BOM from within the same monorepo via `<scope>import</scope>` in a `<dependencyManagement>` block, Maven **does not** recognize it as a concrete build dependency. | ||||||
| * *Example:* `google-cloud-bigtable-deps-bom` imports `google-cloud-monitoring-bom` via `<dependencyManagement>`. | ||||||
| * Running `mvn compile -pl java-bigtable/google-cloud-bigtable -am` (or targeting the deps-bom directly) will **succeed without actually building the local version of `google-cloud-monitoring-bom`**. Any local changes you made to the BOM will be silently ignored because `-am` does not trace imports. | ||||||
|
|
||||||
| #### The Solution (Fast Targeted Build): | ||||||
| To resolve this without doing a full 30-minute monorepo build, you can explicitly list the imported BOMs in the `-pl` parameter. This registers them as primary targets so that `-am` builds them and their dependencies, taking **only ~1 minute**: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the repository's general rules, documentation should clarify that
Suggested change
References
|
||||||
|
|
||||||
| ```bash | ||||||
| mvn install -pl java-monitoring/google-cloud-monitoring-bom,java-bigtable/google-cloud-bigtable-deps-bom,java-bigtable/google-cloud-bigtable -am -P quick-build -DskipTests | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## 2. Building All Submodules under a Service Directory | ||||||
|
|
||||||
| Many services in this repository (e.g., `java-spanner`, `java-bigtable`) are structured as aggregator parents with multiple submodules (e.g., separate directories for client code, gRPC/Protobuf stubs, executors, and BOMs). | ||||||
|
|
||||||
| Once your external dependencies are installed in your local `~/.m2/repository` cache, you can navigate directly to the service folder and run standard Maven commands: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The term "external dependencies" usually refers to third-party libraries (like those from Maven Central). In the context of this monorepo guide, it is clearer to refer to them as "upstream monorepo dependencies" (such as
Suggested change
References
|
||||||
|
|
||||||
| ```bash | ||||||
| cd java-spanner | ||||||
| mvn compile | ||||||
| ``` | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The projects
gax-javaandgoogle-auth-library-javaare external repositories and are not part of thegoogle-cloud-javamonorepo reactor. Maven's-am(also make) flag only builds upstream projects that are defined as modules within the same reactor. Including them in this list might mislead developers into thinking they will be built from source.