|
| 1 | +# Java CI/CD Template Project |
| 2 | + |
| 3 | +This repository serves as a **template project for Java development**, designed to demonstrate and standardize **continuous integration (CI) and code quality practices** for Java projects. It provides a ready-to-use configuration for automated builds, static analysis, and formatting checks. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Key Features |
| 8 | + |
| 9 | +- **Gradle-based build system** |
| 10 | + - Java compilation, testing, and packaging. |
| 11 | + - ErrorProne static analysis integrated. |
| 12 | + - PMD and SpotBugs for code quality checks. |
| 13 | + |
| 14 | +- **Code formatting and style enforcement** |
| 15 | + - [Spotless](https://github.com/diffplug/spotless) with Google Java Format (AOSP variant). |
| 16 | + - [Checkstyle](https://checkstyle.org/) for consistent coding style. |
| 17 | + |
| 18 | +- **Pre-commit hooks** |
| 19 | + - Ensures code quality checks run automatically before commits. |
| 20 | + - Cross-platform support (Windows, macOS, Linux). |
| 21 | + - Includes hooks for formatting, linting, and other safety checks. |
| 22 | + |
| 23 | +- **GitHub Actions CI workflow** |
| 24 | + - Automatically runs all code quality and build checks on pull requests. |
| 25 | + - Uploads reports for easy inspection. |
| 26 | + - Demonstrates a modern CI/CD setup for Java projects. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Getting Started |
| 31 | + |
| 32 | +### Prerequisites |
| 33 | + |
| 34 | +- **Java 25+** |
| 35 | +- **Gradle** (wrapper included) |
| 36 | +- **Python 3.8+** (for `pre-commit`) |
| 37 | +- **Pre-commit**: Install via `pip install pre-commit` |
| 38 | + |
| 39 | +### Setup |
| 40 | + |
| 41 | +1. Install pre-commit hooks: |
| 42 | + |
| 43 | +```bash |
| 44 | +python -m pre_commit install |
| 45 | +``` |
| 46 | + |
| 47 | +2. Run all pre-commit checks manually (optional): |
| 48 | + |
| 49 | +```bash |
| 50 | +python -m pre_commit run --all-files --verbose |
| 51 | +``` |
| 52 | + |
| 53 | +3. Run all code quality checks: |
| 54 | + |
| 55 | +```bash |
| 56 | +./gradlew codeQuality |
| 57 | +``` |
| 58 | + |
| 59 | +The codeQuality task aggregates Spotless, Checkstyle, SpotBugs, and PMD checks in a single step. |
0 commit comments