Checkstyle on Changed Files with Gradle
Article Summary
Marc Prengemann from mobile.de faced 30,000+ Checkstyle violations in their Android codebase. Instead of grinding to a halt, his team found a smarter way forward.
The mobile.de Android team integrated Checkstyle into their PR review process but discovered their legacy codebase had tens of thousands of existing violations. Rather than attempting a massive cleanup, they built a custom Gradle task to check only modified files in pull requests, enabling incremental improvement without blocking development.
Key Takeaways
- Custom Gradle task runs Checkstyle only on changed files between branches
- Integrates with GitHub PR builder plugin for automated Jenkins checks
- Uses Git diff commands to identify modified Java files dynamically
- Enables incremental code quality improvement without massive refactoring
Critical Insight
A custom Gradle task that runs Checkstyle only on PR changes lets teams enforce coding standards on new code while tackling legacy violations incrementally.