xref: /aosp_15_r20/external/leakcanary2/docs/dev-env.md (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)
1# Dev Environment for LeakCanary contributors
2
3## Setup
4* Download [Android Studio](https://developer.android.com/studio).
5* We use two spaces code indentation, use `SquareAndroid` code style settings from https://github.com/square/java-code-styles.
6* Build with `./gradlew build`.
7* Running the failing UI tests to confirm leak detection correctly fails UI tests: `./gradlew leakcanary-android-sample:connectedCheck`.
8* Normal UI tests: `./gradlew leakcanary-android-core:connectedCheck`.
9
10## Static Code Analysis
11* LeakCanary [uses](https://github.com/square/leakcanary/pull/1535) [Detekt](https://arturbosch.github.io/detekt/) for static Code analysis.
12* 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  * 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  * You can bypass the git hook though; Travis CI will still run checks and will fail if any violations are found.
15* Detekt report will be printed in the console and saved to `/moduleDir/build/reports/`.
16
17## Deploying locally
18
19To deploy LeakCanary to your local maven repository, run the following command, changing the path to the path of your local repository:
20
21```
22./gradlew uploadArchives -PSNAPSHOT_REPOSITORY_URL=file:///Users/py/.m2/repository
23```
24
25Then add the SNAPSHOT dependency and `mavenLocal()` repository to your project:
26
27```gradle
28dependencies {
29  debugImplementation 'com.squareup.leakcanary:leakcanary-android:{{ leak_canary.next_release }}-SNAPSHOT'
30}
31
32repositories {
33  mavenLocal()
34}
35```
36
37## Deploying the docs locally
38
39Installing or updating the docs dependencies:
40
41```
42pip install --requirement docs/requirements.txt
43```
44
45Deploying locally
46
47```
48mkdocs serve
49```
50