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