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 any Google project must be accompanied by a Contributor License 9Agreement. This is necessary because you own the copyright to your changes, even 10after your contribution becomes part of this project. So this agreement simply 11gives us permission to use and redistribute your contributions as part of the 12project. Head over to <https://cla.developers.google.com/> to see your current 13agreements on file or to sign a new one. 14 15You generally only need to submit a CLA once, so if you've already submitted one 16(even if it was for a different project), you probably don't need to do it 17again. 18 19## Code reviews 20 21All submissions, including submissions by project members, require review. We 22use GitHub pull requests for this purpose. Consult [GitHub Help] for more 23information on using pull requests. 24 25[GitHub Help]: https://help.github.com/articles/about-pull-requests/ 26 27## Building Dagger 28 29Dagger is built with [`bazel`](https://bazel.build). 30 31### Building Dagger from the command line 32 33* [Install Bazel](https://docs.bazel.build/versions/master/install.html) 34* Build the Dagger project with `bazel build <target>` 35 * Learn more about Bazel targets [here][bazel targets]. 36 * Building Dagger's Android targets requires additional setup: 37 * Set the `ANDROID_HOME` environment variable to point to a directory 38 containing the Android SDK. If you do not have the Android SDK 39 installed, you'll have to 40 [download](https://developer.android.com/studio#command-tools) 41 and unzip it first. 42 * Install the necessary components. For example, under Linux, run: 43 `$ANDROID_HOME/tools/bin/sdkmanager "platforms;android-30" "build-tools;30.0.2"` 44 * If you skip this step, you will see an error similar to 45 `ERROR: missing input file '@androidsdk//:build-tools/30.0.2/aapt'`. 46 * You may also need to run `bazel sync`. 47* Run tests with `bazel test <target>`, or `bazel test //...` to run all 48 tests. 49* You can install the Dagger libraries in your **local maven repository** by 50 running the `./util/install-local-snapshot.sh` script. 51 * It will build the libraries and install them with a `LOCAL-SNAPSHOT` 52 version. 53 54[bazel targets]: https://docs.bazel.build/versions/master/build-ref.html 55 56### Importing the Dagger project in IntelliJ/Android Studio 57 58* Visit `Preferences > Plugins` in the IDE menu. 59 * Search for `bazel` and install the plugin. 60 * If no result shows up, click on `Search in repositories`, search for 61 `bazel` and install the plugin. 62* Select `Import Bazel Project`. 63* Input the path to the Dagger project under `workspace`, click `Next`. 64* Select `Generate from BUILD file`, type `BUILD` in the `Build file` input, 65 click `Next`. 66* [Android Studio only] In the `Project View` form, uncomment one of the 67 `android_sdk_platform` lines. Pick one that you have installed, then click 68 `Finish`. 69* If you get an error on Bazel sync, `Cannot run program "bazel"`, then: 70 * In the command line, run `where bazel` and copy the output (e.g. 71 `/usr/local/bin/bazel`) 72 * In Android Studio, go to `Preferences > Bazel Settings` and replace 73 `Bazel binary location` with what you just copied. 74* Note that the first sync can take a long time. When build files are changed, 75 you can run partial syncs (which should be faster) from the file menu. 76* [Android Studio only] To view the Dagger project structure, open the 77 `Project` view and switch the top selector from `Android` to `Project`. 78