xref: /aosp_15_r20/external/google-auth-library-java/CONTRIBUTING.md (revision af546375c95127f07cb26dd492629ccb2e8b1be1)
1*af546375SCole Faust# How to Contribute
2*af546375SCole Faust
3*af546375SCole FaustWe'd love to accept your patches and contributions to this project. There are
4*af546375SCole Faustjust a few small guidelines you need to follow.
5*af546375SCole Faust
6*af546375SCole Faust## Contributor License Agreement
7*af546375SCole Faust
8*af546375SCole FaustContributions to this project must be accompanied by a Contributor License
9*af546375SCole FaustAgreement. You (or your employer) retain the copyright to your contribution;
10*af546375SCole Faustthis simply gives us permission to use and redistribute your contributions as
11*af546375SCole Faustpart of the project. Head over to <https://cla.developers.google.com/> to see
12*af546375SCole Faustyour current agreements on file or to sign a new one.
13*af546375SCole Faust
14*af546375SCole FaustYou generally only need to submit a CLA once, so if you've already submitted one
15*af546375SCole Faust(even if it was for a different project), you probably don't need to do it
16*af546375SCole Faustagain.
17*af546375SCole Faust
18*af546375SCole Faust## Code reviews
19*af546375SCole Faust
20*af546375SCole FaustAll submissions, including submissions by project members, require review. We
21*af546375SCole Faustuse GitHub pull requests for this purpose. Consult
22*af546375SCole Faust[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23*af546375SCole Faustinformation on using pull requests.
24*af546375SCole Faust
25*af546375SCole Faust## Community Guidelines
26*af546375SCole Faust
27*af546375SCole FaustThis project follows
28*af546375SCole Faust[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
29*af546375SCole Faust
30*af546375SCole Faust## Building the project
31*af546375SCole Faust
32*af546375SCole FaustTo build, package, and run all unit tests run the command
33*af546375SCole Faust
34*af546375SCole Faust```
35*af546375SCole Faustmvn clean verify
36*af546375SCole Faust```
37*af546375SCole Faust
38*af546375SCole Faust### Running Integration tests
39*af546375SCole Faust
40*af546375SCole FaustTo include integration tests when building the project, you need access to
41*af546375SCole Fausta GCP Project with a valid service account.
42*af546375SCole Faust
43*af546375SCole FaustFor instructions on how to generate a service account and corresponding
44*af546375SCole Faustcredentials JSON see: [Creating a Service Account][1].
45*af546375SCole Faust
46*af546375SCole FaustThen run the following to build, package, run all unit tests and run all
47*af546375SCole Faustintegration tests.
48*af546375SCole Faust
49*af546375SCole Faust```bash
50*af546375SCole Faustexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
51*af546375SCole Faustmvn -Penable-integration-tests clean verify
52*af546375SCole Faust```
53*af546375SCole Faust
54*af546375SCole Faust## Code Samples
55*af546375SCole Faust
56*af546375SCole FaustAll code samples must be in compliance with the [java sample formatting guide][3].
57*af546375SCole FaustCode Samples must be bundled in separate Maven modules.
58*af546375SCole Faust
59*af546375SCole FaustThe samples must be separate from the primary project for a few reasons:
60*af546375SCole Faust1. Primary projects have a minimum Java version of Java 8 whereas samples can have
61*af546375SCole Faust   Java version of Java 11. Due to this we need the ability to
62*af546375SCole Faust   selectively exclude samples from a build run.
63*af546375SCole Faust2. Many code samples depend on external GCP services and need
64*af546375SCole Faust   credentials to access the service.
65*af546375SCole Faust3. Code samples are not released as Maven artifacts and must be excluded from
66*af546375SCole Faust   release builds.
67*af546375SCole Faust
68*af546375SCole Faust### Building
69*af546375SCole Faust
70*af546375SCole Faust```bash
71*af546375SCole Faustmvn clean verify
72*af546375SCole Faust```
73*af546375SCole Faust
74*af546375SCole FaustSome samples require access to GCP services and require a service account:
75*af546375SCole Faust
76*af546375SCole Faust```bash
77*af546375SCole Faustexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
78*af546375SCole Faustmvn clean verify
79*af546375SCole Faust```
80*af546375SCole Faust
81*af546375SCole Faust### Code Formatting
82*af546375SCole Faust
83*af546375SCole FaustCode in this repo is formatted with
84*af546375SCole Faust[google-java-format](https://github.com/google/google-java-format).
85*af546375SCole FaustTo run formatting on your project, you can run:
86*af546375SCole Faust```
87*af546375SCole Faustmvn com.coveo:fmt-maven-plugin:format
88*af546375SCole Faust```
89*af546375SCole Faust
90*af546375SCole Faust[1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account
91*af546375SCole Faust[2]: https://maven.apache.org/settings.html#Active_Profiles
92*af546375SCole Faust[3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md