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 31Ensure that Dagger is checked out on a case-sensitive filesystem. On a 32case-insensitive file system (e.g. Windows or MacOS by default) some tasks that 33attempt to delete the `build/` folder will also delete the bazel `BUILD` files. 34 35### Building Dagger from the command line 36 37* [Install Bazel](https://docs.bazel.build/versions/master/install.html) 38* Build the Dagger project with `bazel build <target>` 39 * Learn more about Bazel targets [here][bazel targets]. 40 * Building Dagger's Android targets requires additional setup: 41 * Set the `ANDROID_HOME` environment variable to point to a directory 42 containing the Android SDK. If you do not have the Android SDK 43 installed, you'll have to 44 [download](https://developer.android.com/studio#command-tools) 45 and unzip it first. 46 * Install the necessary components. For example, under Linux, run: 47 `$ANDROID_HOME/tools/bin/sdkmanager "platforms;android-32" "build-tools;32.0.0"` 48 * If you skip this step, you will see an error similar to 49 `ERROR: missing input file '@androidsdk//:build-tools/32.0.0/aapt'`. 50 * You may also need to run `bazel sync`. 51* Run tests with `bazel test <target>`, or `bazel test //...` to run all 52 tests. 53* You can install the Dagger libraries in your **local maven repository** by 54 running the `./util/install-local-snapshot.sh` script. 55 * It will build the libraries and install them with a `LOCAL-SNAPSHOT` 56 version. 57 58[bazel targets]: https://docs.bazel.build/versions/master/build-ref.html 59 60### Importing the Dagger project in IntelliJ/Android Studio 61 62* Visit `Preferences > Plugins` in the IDE menu. 63 * Search for `bazel` and install the plugin. 64 * If no result shows up, click on `Search in repositories`, search for 65 `bazel` and install the plugin. 66* Select `Import Bazel Project`. 67* Input the path to the Dagger project under `workspace`, click `Next`. 68* Select `Generate from BUILD file`, type `BUILD` in the `Build file` input, 69 click `Next`. 70* [Android Studio only] In the `Project View` form, uncomment one of the 71 `android_sdk_platform` lines. Pick one that you have installed, then click 72 `Finish`. 73* If you get an error on Bazel sync, `Cannot run program "bazel"`, then: 74 * In the command line, run `where bazel` and copy the output (e.g. 75 `/usr/local/bin/bazel`) 76 * In Android Studio, go to `Preferences > Bazel Settings` and replace 77 `Bazel binary location` with what you just copied. 78* Note that the first sync can take a long time. When build files are changed, 79 you can run partial syncs (which should be faster) from the file menu. 80* [Android Studio only] To view the Dagger project structure, open the 81 `Project` view and switch the top selector from `Android` to `Project`. 82