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