|
| 1 | +# Contributing | Firebase Admin Java SDK |
| 2 | + |
| 3 | +Thank you for contributing to the Firebase community! |
| 4 | + |
| 5 | + - [Have a usage question?](#question) |
| 6 | + - [Think you found a bug?](#issue) |
| 7 | + - [Have a feature request?](#feature) |
| 8 | + - [Want to submit a pull request?](#submit) |
| 9 | + - [Need to get set up locally?](#local-setup) |
| 10 | + |
| 11 | + |
| 12 | +## <a name="question"></a>Have a usage question? |
| 13 | + |
| 14 | +We get lots of those and we love helping you, but GitHub is not the best place for them. Issues |
| 15 | +which just ask about usage will be closed. Here are some resources to get help: |
| 16 | + |
| 17 | +- Go through the [guides](https://firebase.google.com/docs/admin/setup/) |
| 18 | +- Read the full [API reference](https://firebase.google.com/docs/reference/admin/java/) |
| 19 | + |
| 20 | +If the official documentation doesn't help, try asking a question on the |
| 21 | +[Firebase Google Group](https://groups.google.com/forum/#!forum/firebase-talk/) or one of our |
| 22 | +other [official support channels](https://firebase.google.com/support/). |
| 23 | + |
| 24 | +**Please avoid double posting across multiple channels!** |
| 25 | + |
| 26 | + |
| 27 | +## <a name="issue"></a>Think you found a bug? |
| 28 | + |
| 29 | +Yeah, we're definitely not perfect! |
| 30 | + |
| 31 | +Search through [old issues](https://github.com/firebase/firebase-admin-java/issues) before |
| 32 | +submitting a new issue as your question may have already been answered. |
| 33 | + |
| 34 | +If your issue appears to be a bug, and hasn't been reported, |
| 35 | +[open a new issue](https://github.com/firebase/firebase-admin-java/issues/new). Please use the |
| 36 | +provided bug report template and include a minimal repro. |
| 37 | + |
| 38 | +If you are up to the challenge, [submit a pull request](#submit) with a fix! |
| 39 | + |
| 40 | + |
| 41 | +## <a name="feature"></a>Have a feature request? |
| 42 | + |
| 43 | +Great, we love hearing how we can improve our products! Share you idea through our |
| 44 | +[feature request support channel](https://firebase.google.com/support/contact/bugs-features/). |
| 45 | + |
| 46 | + |
| 47 | +## <a name="submit"></a>Want to submit a pull request? |
| 48 | + |
| 49 | +Sweet, we'd love to accept your contribution! |
| 50 | +[Open a new pull request](https://github.com/firebase/firebase-admin-java/pull/new/master) and fill |
| 51 | +out the provided template. |
| 52 | + |
| 53 | +**If you want to implement a new feature, please open an issue with a proposal first so that we can |
| 54 | +figure out if the feature makes sense and how it will work.** |
| 55 | + |
| 56 | +Make sure your changes pass our linter and the tests all pass on your local machine. |
| 57 | +Most non-trivial changes should include some extra test coverage. If you aren't sure how to add |
| 58 | +tests, feel free to submit regardless and ask us for some advice. |
| 59 | + |
| 60 | +Finally, you will need to sign our |
| 61 | +[Contributor License Agreement](https://cla.developers.google.com/about/google-individual) |
| 62 | +before we can accept your pull request. |
| 63 | + |
| 64 | + |
| 65 | +## <a name="local-setup"></a>Need to get set up locally? |
| 66 | + |
| 67 | +### Initial Setup |
| 68 | + |
| 69 | +Install Java 7 or higher. You can also use Java 8, but please note that the Firebase Admin SDK must |
| 70 | +maintain full Java 7 compatibility. Therefore make sure that you do not use any Java 8 features |
| 71 | +(e.g. lambdas) when writing code for the Admin Java SDK. |
| 72 | + |
| 73 | +We use [Apache Maven](http://maven.apache.org/) for building, testing and releasing the Admin Java |
| 74 | +SDK code. Follow the [installation guide](http://maven.apache.org/install.html), and install Maven |
| 75 | +3.3 or higher. |
| 76 | + |
| 77 | +### Running Linters |
| 78 | + |
| 79 | +[Maven Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin/) is configured |
| 80 | +to run everytime the build is invoked. This plugin verifies source code format, and enforces a |
| 81 | +number of other Java programming best practices. Any style violations will cause the build to break. |
| 82 | + |
| 83 | +Configuration for the Checkstyle plugin can be found in the `checkstyle.xml` file at the root of the |
| 84 | +repository. To execute only the linter without rest of the build pipeline, execute the following |
| 85 | +command: |
| 86 | + |
| 87 | +``` |
| 88 | +mvn validate |
| 89 | +``` |
| 90 | + |
| 91 | +If you are using Eclipse for development, you can install the |
| 92 | +[Eclipse Checkstyle plugin](http://eclipse-cs.sourceforge.net/#!/), and import the `checkstyle.xml` |
| 93 | +file into the IDE. This enables you to have the linter constantly checking your code as you develop. |
| 94 | +A similar [plugin](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea) is available for |
| 95 | +IntelliJ IDEA as well. |
| 96 | + |
| 97 | +### Unit Testing |
| 98 | + |
| 99 | +Tests are implemented using the [Junit4](http://junit.org/junit4/) framework, and are housed under |
| 100 | +the `src/test` subdirectory. They get executed as part of the build, and test failures will cause |
| 101 | +the build to break. To run the unit tests without the rest of the build pipeline, execute the |
| 102 | +following command: |
| 103 | + |
| 104 | +``` |
| 105 | +mvn test |
| 106 | +``` |
| 107 | + |
| 108 | +### Integration Testing |
| 109 | + |
| 110 | +Integration tests are also written using Junit4. They coexist with the unit tests in the `src/test` |
| 111 | +subdirectory. Integration tests follow the naming convention `*IT.java` (e.g. `DataTestIT.java`), |
| 112 | +which enables the Maven Surefire and Failsafe plugins to differentiate between the two types of |
| 113 | +tests. Integration tests are executed against a real life Firebase project, and therefore |
| 114 | +requires an Internet connection. Create a new project in the |
| 115 | +[Firebase console](https://console.firebase.google.com/) if you do not already have one. Use a |
| 116 | +separate, dedicated project for integration tests since the test suite makes a large number of |
| 117 | +writes to the Firebase realtime database. Download the service account private key from the |
| 118 | +"Settings" page of the project. Now run the following command to invoke the integration test suite: |
| 119 | + |
| 120 | +``` |
| 121 | +mvn verify -Dfirebase.it.certificate=path/to/your/serviceAccount.json |
| 122 | +``` |
| 123 | + |
| 124 | +Make sure to specify the correct path to your downloaded service account key file as the |
| 125 | +`firebase.it.certificate` system property. |
| 126 | + |
| 127 | +The above command invokes both unit and integration test suites. To execute only the integration |
| 128 | +tests, run the command as follows: |
| 129 | + |
| 130 | +``` |
| 131 | +mvn verify -Dfirebase.it.certificate=path/to/your/serviceAccount.json -Dskip.surefire.tests=true |
| 132 | +``` |
| 133 | + |
| 134 | + |
| 135 | + |
0 commit comments