Gradle Plugin to automatically detect unused code on your Kotlin or Android project
// TODO
Add the following configuration to your root build.gradle
, replacing X.Y.Z with the latest version
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.dipien:bye-bye-dead-code:X.Y.Z")
}
}
apply plugin: "com.dipien.bye-bye-dead-code"
// TODO
This task depends on R8 which detects unused code when you build your project. So you must enable minifyEnabled
in the build.gradle
of your app module. See how to configure R8
./gradlew app:bundleRelease generateDeadCodeReport
The report app/build/outputs/dead_code/usage.txt
will be generated.
The extension is configured by default to work using the release build type, but you can change this if you want. Using the extension byeByeDeadCode
you can modify the following properties:
Name | Type | Description |
---|---|---|
ignoredClasses | List | Optional. List of ignored classes. Supports regex. |
ignoredMembers | List | Optional. List of ignored class members. Supports regex. |
generatedClassesDirs | List | Required. Directories that are used by different tools (e.g. kapt) to store generated source code. Default: ["build/generated/source/kapt/release", "build/generated/source/navigation-args/release"] |
compiledKotlinClassesDir | String | Required. Directory where compiled kotlin classes are stored. Default: "build/tmp/kotlin-classes/release" |
compiledJavaClassesDir | String | Required. Directory where compiled Java classes are stored. Default: "build/intermediates/javac/release" |
r8UsageFilePath | String | Required. File path of usage.txt generated by R8. Default: "app/build/outputs/mapping/release/usage.txt" |
reportFilePath | String | Required. File path to store the report. Default: "app/build/outputs/dead_code/usage.txt" |
Remove unused Android resources
./gradlew removeUnusedAndroidResources
Part of the source code of this project is based on Unused Resources Remover for Android
This project uses the Semantic Versioning guidelines for transparency into our release cycle.
Sponsor this open source project to help us get the funding we need to continue working on it.
- Donate with Bitcoin Lightning ⚡️ dipien@getalby.com
- Donate cryptocurrency
- Donate with PayPal
- Donate on Patreon
- Become a member of Medium [We will receive a portion of your membership fee]