aboutsummaryrefslogtreecommitdiff
path: root/CONTRIBUTING.md
blob: 8975bcbc395337a660ef10d15587d8c583579754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# How to contribute

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.

## Contributor License Agreement

Contributions to any Google project must be accompanied by a Contributor License
Agreement. This is necessary because you own the copyright to your changes, even
after your contribution becomes part of this project. So this agreement simply
gives us permission to use and redistribute your contributions as part of the
project. Head over to <https://cla.developers.google.com/> to see your current
agreements on file or to sign a new one.

You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.

## Code reviews

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult [GitHub Help] for more
information on using pull requests.

[GitHub Help]: https://help.github.com/articles/about-pull-requests/

## Building Dagger

Dagger is built with [`bazel`](https://bazel.build).

Ensure that Dagger is checked out on a case-sensitive filesystem. On a
case-insensitive file system (e.g. Windows or MacOS by default) some tasks that
attempt to delete the `build/` folder will also delete the bazel `BUILD` files.

### Building Dagger from the command line

*   [Install Bazel](https://docs.bazel.build/versions/master/install.html)
*   Build the Dagger project with `bazel build <target>`
    *   Learn more about Bazel targets [here][bazel targets].
    *   Building Dagger's Android targets requires additional setup:
        *   Set the `ANDROID_HOME` environment variable to point to a directory
            containing the Android SDK. If you do not have the Android SDK
            installed, you'll have to
            [download](https://developer.android.com/studio#command-tools)
            and unzip it first.
        *   Install the necessary components. For example, under Linux, run:
            `$ANDROID_HOME/tools/bin/sdkmanager "platforms;android-32" "build-tools;32.0.0"`
            *   If you skip this step, you will see an error similar to
                `ERROR: missing input file '@androidsdk//:build-tools/32.0.0/aapt'`.
            *   You may also need to run `bazel sync`.
*   Run tests with `bazel test <target>`, or `bazel test //...` to run all
    tests.
*   You can install the Dagger libraries in your **local maven repository** by
    running the `./util/install-local-snapshot.sh` script.
    *   It will build the libraries and install them with a `LOCAL-SNAPSHOT`
        version.

[bazel targets]: https://docs.bazel.build/versions/master/build-ref.html

### Importing the Dagger project in IntelliJ/Android Studio

*   Visit `Preferences > Plugins` in the IDE menu.
    *   Search for `bazel` and install the plugin.
    *   If no result shows up, click on `Search in repositories`, search for
        `bazel` and install the plugin.
*   Select `Import Bazel Project`.
*   Input the path to the Dagger project under `workspace`, click `Next`.
*   Select `Generate from BUILD file`, type `BUILD` in the `Build file` input,
    click `Next`.
*   [Android Studio only] In the `Project View` form, uncomment one of the
    `android_sdk_platform` lines. Pick one that you have installed, then click
    `Finish`.
*   If you get an error on Bazel sync, `Cannot run program "bazel"`, then:
    *   In the command line, run `where bazel` and copy the output  (e.g.
        `/usr/local/bin/bazel`)
    *   In Android Studio, go to `Preferences > Bazel Settings` and replace
        `Bazel binary location` with what you just copied.
*   Note that the first sync can take a long time. When build files are changed,
    you can run partial syncs (which should be faster) from the file menu.
*   [Android Studio only] To view the Dagger project structure, open the
    `Project` view and switch the top selector from `Android` to `Project`.