xref: /aosp_15_r20/external/leakcanary2/docs/dev-env.md (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)
1*d9e8da70SAndroid Build Coastguard Worker# Dev Environment for LeakCanary contributors
2*d9e8da70SAndroid Build Coastguard Worker
3*d9e8da70SAndroid Build Coastguard Worker## Setup
4*d9e8da70SAndroid Build Coastguard Worker* Download [Android Studio](https://developer.android.com/studio).
5*d9e8da70SAndroid Build Coastguard Worker* We use two spaces code indentation, use `SquareAndroid` code style settings from https://github.com/square/java-code-styles.
6*d9e8da70SAndroid Build Coastguard Worker* Build with `./gradlew build`.
7*d9e8da70SAndroid Build Coastguard Worker* Running the failing UI tests to confirm leak detection correctly fails UI tests: `./gradlew leakcanary-android-sample:connectedCheck`.
8*d9e8da70SAndroid Build Coastguard Worker* Normal UI tests: `./gradlew leakcanary-android-core:connectedCheck`.
9*d9e8da70SAndroid Build Coastguard Worker
10*d9e8da70SAndroid Build Coastguard Worker## Static Code Analysis
11*d9e8da70SAndroid Build Coastguard Worker* LeakCanary [uses](https://github.com/square/leakcanary/pull/1535) [Detekt](https://arturbosch.github.io/detekt/) for static Code analysis.
12*d9e8da70SAndroid Build Coastguard Worker* Analyze the entire project with `./gradlew check` or particular modules with `./gradlew :module-name:check`. Detekt will fail the build if any ruleset violations are found. **You should fix all issues before pushing the branch to remote**.
13*d9e8da70SAndroid Build Coastguard Worker  * There's also a **git pre-push** hook that will run analysis automatically before pushing a branch to the remote. If there are any violations - it will prevent the push. Fix the issues!
14*d9e8da70SAndroid Build Coastguard Worker  * You can bypass the git hook though; Travis CI will still run checks and will fail if any violations are found.
15*d9e8da70SAndroid Build Coastguard Worker* Detekt report will be printed in the console and saved to `/moduleDir/build/reports/`.
16*d9e8da70SAndroid Build Coastguard Worker
17*d9e8da70SAndroid Build Coastguard Worker## Deploying locally
18*d9e8da70SAndroid Build Coastguard Worker
19*d9e8da70SAndroid Build Coastguard WorkerTo deploy LeakCanary to your local maven repository, run the following command, changing the path to the path of your local repository:
20*d9e8da70SAndroid Build Coastguard Worker
21*d9e8da70SAndroid Build Coastguard Worker```
22*d9e8da70SAndroid Build Coastguard Worker./gradlew uploadArchives -PSNAPSHOT_REPOSITORY_URL=file:///Users/py/.m2/repository
23*d9e8da70SAndroid Build Coastguard Worker```
24*d9e8da70SAndroid Build Coastguard Worker
25*d9e8da70SAndroid Build Coastguard WorkerThen add the SNAPSHOT dependency and `mavenLocal()` repository to your project:
26*d9e8da70SAndroid Build Coastguard Worker
27*d9e8da70SAndroid Build Coastguard Worker```gradle
28*d9e8da70SAndroid Build Coastguard Workerdependencies {
29*d9e8da70SAndroid Build Coastguard Worker  debugImplementation 'com.squareup.leakcanary:leakcanary-android:{{ leak_canary.next_release }}-SNAPSHOT'
30*d9e8da70SAndroid Build Coastguard Worker}
31*d9e8da70SAndroid Build Coastguard Worker
32*d9e8da70SAndroid Build Coastguard Workerrepositories {
33*d9e8da70SAndroid Build Coastguard Worker  mavenLocal()
34*d9e8da70SAndroid Build Coastguard Worker}
35*d9e8da70SAndroid Build Coastguard Worker```
36*d9e8da70SAndroid Build Coastguard Worker
37*d9e8da70SAndroid Build Coastguard Worker## Deploying the docs locally
38*d9e8da70SAndroid Build Coastguard Worker
39*d9e8da70SAndroid Build Coastguard WorkerInstalling or updating the docs dependencies:
40*d9e8da70SAndroid Build Coastguard Worker
41*d9e8da70SAndroid Build Coastguard Worker```
42*d9e8da70SAndroid Build Coastguard Workerpip install --requirement docs/requirements.txt
43*d9e8da70SAndroid Build Coastguard Worker```
44*d9e8da70SAndroid Build Coastguard Worker
45*d9e8da70SAndroid Build Coastguard WorkerDeploying locally
46*d9e8da70SAndroid Build Coastguard Worker
47*d9e8da70SAndroid Build Coastguard Worker```
48*d9e8da70SAndroid Build Coastguard Workermkdocs serve
49*d9e8da70SAndroid Build Coastguard Worker```
50