Find and remove unused code before it becomes technical debt.
A powerful Gradle plugin that detects unused classes, methods, fields, resources, and dependencies across JVM, Spring Boot, Android, and Kotlin Multiplatform projects.
📱 Looking for the Android version?
👉 https://github.com/arya458/Dead-Code-Detector-Gradle-Plugin/tree/main/PluginAndroid
- Why Dead Code Detector?
- Features
- Installation
- Configuration
- Reports
- How It Works
- Supported Platforms
- Roadmap
- Contributing
- License
- Contact
As projects grow, unused code inevitably accumulates.
Dead classes, methods, fields, resources, and dependencies increase maintenance costs, slow down development, and make codebases harder to understand.
Dead Code Detector helps you automatically identify unused code so you can safely remove it and keep your project clean and maintainable.
| Feature | Supported |
|---|---|
| Detect unused classes | ✅ |
| Detect unused methods | ✅ |
| Detect unused fields | ✅ |
| Detect unused dependencies | ✅ |
| Detect unused Android resources | ✅ |
| Spring Boot support | ✅ |
| Kotlin Multiplatform support | ✅ |
| JVM projects | ✅ |
| Platform-aware keep rules | ✅ |
| Custom keep annotations | ✅ |
| Parallel scanning | ✅ |
| Interactive HTML report | ✅ |
| JSON report | ✅ |
| Plain text report | ✅ |
Add the plugin to your build.gradle.kts.
plugins {
id("io.github.arya458.dead-code-detector") version "0.0.10"
}Run:
./gradlew deadCodeDetectordeadCodeDetector {
// Fail the build if dead code is found
failOnDeadCode = false
// Include test sources
includeTests = false
// Keep public API
keepPublicApi = true
// auto | android | spring | kmm
platform = "auto"
// Resources
includeResources = true
resourceDir = "src/main/res"
testResourceDir = "src/test/res"
// Dependency analysis
analyzeDependencies = true
failOnUnusedDependencies = false
// Spring configuration scanning
scanConfigFiles = true
configDirs = listOf("src/main/resources")
// Exclusions
excludePackages.add("com.example.generated")
excludeClasses.add("com.example.Legacy")
// Keep annotations
keepAnnotations.add("javax.inject.Inject")
// Advanced keep rules
customKeepRules = { type, annotations, method ->
false
}
// Performance
parallelScan = true
}Generated reports are located at:
build/
└── reports/
└── dead-code-detector/
├── report.txt
├── report.html
└── report.json
A human-readable report suitable for terminals and CI logs.
Interactive report with:
- Search
- Filtering
- Statistics
- Grouped results
- Responsive interface
Perfect for:
- CI/CD pipelines
- GitHub Actions
- SonarQube
- Custom tooling
- Automated quality checks
==== Dead Code Detector ====
Dead classes : 5
Dead methods : 18
Dead fields : 9
Unused resources : 14
Unused dependencies : 2
✔ Reports generated successfully
The plugin analyzes compiled bytecode using ASM.
It automatically:
- Collects all classes
- Collects all methods
- Collects all fields
- Tracks references
- Detects unused code
- Scans Android resources
- Scans Spring configuration
- Detects unused Gradle dependencies
- Applies platform-specific keep rules
- Generates detailed reports
| Platform | Status |
|---|---|
| JVM | ✅ |
| Spring Boot | ✅ |
| Android | ✅ |
| Kotlin Multiplatform | ✅ |
Future improvements include:
- IntelliJ IDEA plugin
- Maven plugin
- Automatic dead code removal
- SARIF report generation
- SonarQube integration
- GitHub Code Scanning support
- Incremental analysis
- Performance improvements
Contributions are welcome!
Whether you'd like to:
- 🐞 Report a bug
- ✨ Suggest a feature
- 📖 Improve the documentation
- 💻 Submit a Pull Request
please read CONTRIBUTING.md before contributing.
This project is licensed under the MIT License.
Copyright © 2025 Aria Danesh
See the LICENSE file for details.
Aria Danesh
🐙 GitHub: https://github.com/arya458
If you find this plugin useful, please consider giving the repository a ⭐ on GitHub.
It helps the project reach more developers and motivates future improvements.
Thank you for your support! ❤️