Configuration (full template)
Drop this into your module's build.gradle.kts
. Copy, tweak, and paste.
deadCodeDetector {
// Fail the build if any dead code is detected
failOnDeadCode = true
// Scan test classes + test resources when true
includeTests = false
// If true, public API (public functions/fields) are ignored from detection
keepPublicApi = false
// Resource scanning (optional)
includeResources = false
resourceDir = "src/main/resources"
testResourceDir = "src/test/resources"
// Exclude generated packages (prefix match)
excludePackages.add("com.mycompany.generated")
// Keep items annotated with these annotations
keepAnnotations.add("javax.inject.Inject")
// (Planned) clearAllDeadCode = true // not implemented yet
}
Notes
- If your module is a library, set
keepPublicApi = true
to avoid removing public API used externally. - Use
excludePackages
for generated code (e.g., Dagger/Hilt generated classes).