Dependency Analysis Plugin
> Task :LibraryB:projectHealth
Unused dependencies which should be removed:
implementation("androidx.appcompat:appcompat:1.4.1")
implementation("androidx.core:core-ktx:1.7.0")
implementation("com.google.android.material:material:1.5.0")
Slide 54
Slide 54 text
Dependency Analysis Plugin
Plugin advice:
kotlin-kapt: no used annotation processors
Slide 55
Slide 55 text
Optimizations
● Config time
● Dependencies
● Build cache
Slide 56
Slide 56 text
Build Cache
Task
Output
Cache (id)
Result
Slide 57
Slide 57 text
Build Cache
Task
Output
Cache (id)
Get
Slide 58
Slide 58 text
Gradle Doctor Plugin
• Slower tasks from cache
• Build scan tags
Slide 59
Slide 59 text
Gradle Doctor Plugin
plugins {
id "com.osacky.doctor" version "0.7.3"
}
Slide 60
Slide 60 text
Gradle Doctor Plugin
plugins {
id "com.osacky.doctor" version "0.7.3"
}
Slide 61
Slide 61 text
https:
//
gradle.com/
Gradle
Slide 62
Slide 62 text
Gradle Doctor Plugin
• doctor-negative-savings
• doctor-slow-build-cache-connection
Slide 63
Slide 63 text
How do you disable caching for a task?
Slide 64
Slide 64 text
Disable Local Caching
tasks.named("").configure {
outputs.cacheIf { false }
}
Gradle Doctor Plugin
• Set threshold on Dagger processing
Slide 67
Slide 67 text
Disable Remote Caching
doctor {
/**
* Print a warning to the console if we spend more than this
* amount of time with Dagger annotation processors.
*/
daggerThreshold = 5000
}
Slide 68
Slide 68 text
Android Build Cache Plugin
• Plugin by Gradle
• Gradle plugin to fix Android build problems
• Workarounds for Room
Gradle Profiler
1. Write a performance scenario
2. Specify number of iterations
Slide 111
Slide 111 text
Gradle Profiler
brew install gradle-profiler
Slide 112
Slide 112 text
Performance Scenario
assemble {
# Show a slightly more human-readable title in reports
title = "Assemble"
# Run the 'assemble' task
tasks = ["assemble"]
}
assemble {
}
Slide 113
Slide 113 text
Performance Scenario
assemble {
# Show a slightly more human-readable title in reports
title = "Assemble"
# Run the 'assemble' task
tasks = ["assemble"]
}
assemble {
tasks = ["assemble"]
}
Gradle Profiler
Iteration 1
Iteration 2
Iteration 3
Abi Change
Slide 126
Slide 126 text
Gradle Profiler
Iteration 1
Iteration 2
Iteration 3
Result
Slide 127
Slide 127 text
Performance Scenario
assemble {
# Show a slightly more human-readable title in reports
title = "Assemble"
# Run the 'assemble' task
tasks = ["assemble"]
}
incremental_build {
apply-abi-change-to = “src/main/java/StringUtils.kt”
}
Slide 128
Slide 128 text
Performance Scenario
assemble {
# Show a slightly more human-readable title in reports
title = "Assemble"
# Run the 'assemble' task
tasks = ["assemble"]
}
incremental_build {
apply-abi-change-to = “src/main/java/StringUtils.kt”
apply-android-resource-change-to = “strings.xml”
tasks = ["assemble"]
}
Performance Scenario
assemble {
# Show a slightly more human-readable title in reports
title = "Assemble"
# Run the 'assemble' task
tasks = ["assemble"]
}
androidStudioSync {
android-studio-sync {
}
}
Slide 133
Slide 133 text
Performance Scenario
assemble {
# Show a slightly more human-readable title in reports
title = "Assemble"
# Run the 'assemble' task
tasks = ["assemble"]
}
androidStudioSync {
android-studio-sync {
studio-jvm-args = ["-Xms256m", "-Xmx4096m"]
}
}
Slide 134
Slide 134 text
Gradle Profiler
1. Write a performance scenario
2. Specify number of iterations
Benchmarking Build
• Benchmark with Anvil change
• Benchmark without Anvil change (Baseline)
• Compare results
Slide 146
Slide 146 text
Performance Scenario
assemble {
# Show a slightly more human-readable title in reports
title = "Assemble"
# Run the 'assemble' task
tasks = ["assemble"]
}
incremental_build {
apply-abi-change-to = “src/main/java/StringUtils.kt”
tasks = ["assemble"]
}
Slide 147
Slide 147 text
Results
Module A Module B Module C
Baseline Anvil
Slide 148
Slide 148 text
Summary
• How to setup & run Gradle Profiler
• Performance scenarios
• Anvil