xref: /aosp_15_r20/external/google-cloud-java/CONTRIBUTING.md (revision 55e87721aa1bc457b326496a7ca40f3ea1a63287)
1*55e87721SMatt GilbrideContributing
2*55e87721SMatt Gilbride============
3*55e87721SMatt Gilbride
4*55e87721SMatt Gilbride1. **Please sign one of the contributor license agreements below.**
5*55e87721SMatt Gilbride2. Fork the repo, develop and test your code changes, add docs.
6*55e87721SMatt Gilbride3. Make sure that your commit messages clearly describe the changes.
7*55e87721SMatt Gilbride4. Send a pull request.
8*55e87721SMatt Gilbride
9*55e87721SMatt Gilbride
10*55e87721SMatt GilbrideHere are some guidelines for hacking on google-cloud-java.
11*55e87721SMatt Gilbride
12*55e87721SMatt GilbrideRepository Structure
13*55e87721SMatt Gilbride--------------------
14*55e87721SMatt Gilbride* `google-cloud-java` (`/pom.xml`)
15*55e87721SMatt Gilbride  * The root aggregator POM that lists all of the modules.
16*55e87721SMatt Gilbride  * Does not get released.
17*55e87721SMatt Gilbride* `google-cloud-pom-parent`
18*55e87721SMatt Gilbride  * Serves as the parent POM for the `gapic-libraries-bom` and module mini BOMs.
19*55e87721SMatt Gilbride  * Should not have any dependency management so as not to impact the BOMs.
20*55e87721SMatt Gilbride* `google-cloud-jar-parent`
21*55e87721SMatt Gilbride  * The root POM for all modules.
22*55e87721SMatt Gilbride  * The only POM where non-annotated versions should be managed using `dependencyManagement`.
23*55e87721SMatt Gilbride  * Contains common configuration for `jar` projects.
24*55e87721SMatt Gilbride* `generation`
25*55e87721SMatt Gilbride  * A collection of scripts that are used to make updates across modules.
26*55e87721SMatt Gilbride* `gapic-libraries-bom`
27*55e87721SMatt Gilbride  * A BOM for all non-preview libraries in the monorepo.
28*55e87721SMatt Gilbride* `java-*`
29*55e87721SMatt Gilbride  * Individual client libraries.
30*55e87721SMatt Gilbride
31*55e87721SMatt GilbrideUsing maven for build/test
32*55e87721SMatt Gilbride--------------------------
33*55e87721SMatt Gilbride
34*55e87721SMatt GilbrideTo run the tests, you must have application default credentials in a JSON file on your development machine.
35*55e87721SMatt Gilbride[Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts)
36*55e87721SMatt Gilbridein the cloud console and download they key to a secure location on your development box.
37*55e87721SMatt GilbrideThen set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the location of the JSON file.
38*55e87721SMatt GilbrideFor example:
39*55e87721SMatt Gilbride
40*55e87721SMatt Gilbride  ```bash
41*55e87721SMatt Gilbride  export GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/key.json
42*55e87721SMatt Gilbride   ```
43*55e87721SMatt Gilbride
44*55e87721SMatt GilbrideAfter you clone the repository, use Maven for building and running the tests.
45*55e87721SMatt Gilbride
46*55e87721SMatt GilbrideIntegration tests run tests against real services and take a long time to run.
47*55e87721SMatt GilbrideConsider `mvn install -DskipITs` to skip them when installing.
48*55e87721SMatt GilbrideMaven 3.0+ is required.
49*55e87721SMatt Gilbride
50*55e87721SMatt GilbrideIt's also important to test that changes don't break compatibility with App/Compute Engine and when running elsewhere.
51*55e87721SMatt GilbrideTo run tests on different platforms, try deploying the apps available on the [google-cloud-examples](https://github.com/googleapis/google-cloud-examples) repository.
52*55e87721SMatt GilbrideEnd-to-end tests should ensure that google-cloud-java works when running on the
53*55e87721SMatt Gilbride
54*55e87721SMatt Gilbride* App Engine production environment (see the docs for [uploading your app to production App Engine](https://cloud.google.com/appengine/docs/java/tools/maven#uploading_your_app_to_production_app_engine))
55*55e87721SMatt Gilbride* App Engine development server (see the docs for [testing your app with the development server](https://cloud.google.com/appengine/docs/java/tools/maven#testing_your_app_with_the_development_server))
56*55e87721SMatt Gilbride* Compute Engine (see the [Getting Started Guide](https://cloud.google.com/compute/docs/quickstart), and be sure to [enable the appropriate APIs](https://github.com/googleapis/google-cloud-common/tree/master/authentication#on-google-compute-engine))
57*55e87721SMatt Gilbride* Your desktop (using `mvn exec:java`, for example)
58*55e87721SMatt Gilbride
59*55e87721SMatt GilbrideWhen changes are made to authentication and project ID-related code, authentication and project ID inference should be tested using all relevant methods detailed in the [authentication docs](https://github.com/googleapis/google-cloud-java#authentication) and [project ID docs](https://github.com/googleapis/google-cloud-java#specifying-a-project-id).
60*55e87721SMatt Gilbride
61*55e87721SMatt GilbrideKnown issue: If you have installed the Google Cloud SDK, be sure to log in (using `gcloud auth login`) before running tests. Though the Datastore tests use a local Datastore emulator that doesn't require authentication, they will not run if you have the Google Cloud SDK installed but aren't authenticated.
62*55e87721SMatt Gilbride
63*55e87721SMatt Gilbride**Please, do not use your production projects for executing integration tests.** While we do our best to make our tests independent of your project's state and content, they do perform create, modify and deletes, and you do not want to have your production data accidentally modified.
64*55e87721SMatt Gilbride
65*55e87721SMatt GilbrideAdding Features
66*55e87721SMatt Gilbride---------------
67*55e87721SMatt GilbrideIn order to add a feature to google-cloud-java:
68*55e87721SMatt Gilbride
69*55e87721SMatt GilbrideThe feature must be fully documented using Javadoc and examples should be provided.
70*55e87721SMatt GilbrideThe feature must work fully on Java 7 and above.
71*55e87721SMatt GilbrideThe feature must not add unnecessary dependencies (where "unnecessary" is of course subjective,
72*55e87721SMatt Gilbridebut new dependencies should be discussed).
73*55e87721SMatt Gilbride
74*55e87721SMatt GilbrideAdding Support for a New Service
75*55e87721SMatt Gilbride--------------------------------
76*55e87721SMatt GilbrideSee [SUPPORTING_NEW_SERVICES](./SUPPORTING_NEW_SERVICES.md) for guidelines on how to add support for a new Google Cloud service to `google-cloud-java`.
77*55e87721SMatt Gilbride
78*55e87721SMatt GilbrideCoding Style
79*55e87721SMatt Gilbride------------
80*55e87721SMatt GilbrideMaintain the coding style in the project and in particular the modified files.
81*55e87721SMatt GilbrideFollow the Google Java [style](https://google.github.io/styleguide/javaguide.html).
82*55e87721SMatt Gilbride
83*55e87721SMatt GilbrideIn pull requests, please run `mvn com.coveo:fmt-maven-plugin:format` to format your code diff.
84*55e87721SMatt Gilbride
85*55e87721SMatt Gilbride## Contributor License Agreements
86*55e87721SMatt Gilbride
87*55e87721SMatt GilbrideBefore we can accept your pull requests you'll need to sign a Contributor
88*55e87721SMatt GilbrideLicense Agreement (CLA):
89*55e87721SMatt Gilbride
90*55e87721SMatt Gilbride- **If you are an individual writing original source code** and **you own the intellectual property**,
91*55e87721SMatt Gilbridethen you'll need to sign an [individual CLA][indvcla].
92*55e87721SMatt Gilbride- **If you work for a company that wants to allow you to contribute your work**,
93*55e87721SMatt Gilbridethen you'll need to sign a [corporate CLA][corpcla].
94*55e87721SMatt Gilbride
95*55e87721SMatt GilbrideYou can sign these electronically (just scroll to the bottom). After that,
96*55e87721SMatt Gilbridewe'll be able to accept your pull requests.
97*55e87721SMatt Gilbride
98*55e87721SMatt Gilbride## Code of Conduct
99*55e87721SMatt Gilbride
100*55e87721SMatt GilbridePlease note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
101*55e87721SMatt Gilbride
102*55e87721SMatt Gilbride[gcloudcli]: https://developers.google.com/cloud/sdk/gcloud/
103*55e87721SMatt Gilbride[indvcla]: https://developers.google.com/open-source/cla/individual
104*55e87721SMatt Gilbride[corpcla]: https://developers.google.com/open-source/cla/corporate
105*55e87721SMatt Gilbride[code-of-conduct]:https://github.com/googleapis/google-cloud-java/blob/master/CODE_OF_CONDUCT.md
106