A comprehensive Gradle boilerplate template for Java/Kotlin projects with modern development practices, testing, and CI/CD integration.
- Modern Gradle Setup: Kotlin DSL configuration with Gradle 8.11.1
- Java 17+ Support: Compatible with Java 17 and 21
- Kotlin Integration: Ready for mixed Java/Kotlin projects
- Testing Framework: JUnit 5, AssertJ, and Mockito
- Code Quality: Checkstyle, PMD, SpotBugs integration
- Code Coverage: JaCoCo for test coverage reporting
- CI/CD Pipeline: GitHub Actions workflow
- Multi-platform Testing: Tests on Ubuntu, Windows, and macOS
- Dependency Management: Centralized dependency configuration
- Documentation: Comprehensive README and inline documentation
βββ .github/
β βββ workflows/
β β βββ ci.yml # GitHub Actions CI/CD pipeline
β βββ copilot-instructions.md # GitHub Copilot configuration
βββ config/
β βββ checkstyle/
β β βββ checkstyle.xml # Checkstyle configuration
β βββ pmd/
β β βββ ruleset.xml # PMD rules
β βββ spotbugs/
β βββ exclude.xml # SpotBugs exclusions
βββ gradle/
β βββ wrapper/ # Gradle wrapper files
βββ src/
β βββ main/java/ # Main source code
β βββ test/java/ # Test source code
βββ build.gradle.kts # Gradle build script
βββ gradlew # Gradle wrapper (Unix)
βββ gradlew.bat # Gradle wrapper (Windows)
βββ settings.gradle.kts # Gradle settings
- Java 17 or higher
- Git
Important: If you're working in a corporate environment with SSL inspection or proxies, you may encounter SSL certificate errors when first running Gradle. This is because the Gradle wrapper needs to download Gradle itself before it can read the gradle.properties configuration.
-
Run the setup script:
# PowerShell (recommended) .\setup-corporate-network.ps1 # Or Command Prompt setup-corporate-network.bat
-
Manual alternative: Download Gradle manually from https://services.gradle.org/distributions/gradle-8.11.1-all.zip and extract to the project directory.
-
Complete guide: See CORPORATE-NETWORK-GUIDE.md for detailed troubleshooting.
- gradle.properties: Pre-configured with corporate network settings
- setup-corporate-network.ps1: Automated setup script
- CORPORATE-NETWORK-GUIDE.md: Comprehensive troubleshooting guide
- Use this template: Click "Use this template" button on GitHub or clone the repository
- Update project details: Modify package names, project name, and description
- Run tests:
./gradlew test - Build project:
./gradlew build
- Follow corporate setup: See section above for SSL/proxy configuration
- Run setup script:
.\setup-corporate-network.ps1 - Update project details: Same as standard networks
- Build and test: Use provided scripts or manual Gradle download
./gradlew build- Build the entire project./gradlew cleanBuild- Clean and build the project./gradlew run- Run the main application
./gradlew test- Run all tests./gradlew jacocoTestReport- Generate test coverage report./gradlew jacocoTestCoverageVerification- Verify coverage meets threshold
./gradlew codeQuality- Run all code quality checks./gradlew checkstyleMain- Run Checkstyle on main sources./gradlew pmdMain- Run PMD on main sources./gradlew spotbugsMain- Run SpotBugs on main sources
The project uses JUnit 5 as the testing framework with:
- AssertJ for fluent assertions
- Mockito for mocking dependencies
- Test coverage reporting with JaCoCo
Example test structure:
@Test
@DisplayName("Should return greeting message")
void shouldReturnGreetingMessage() {
// Given
App app = new App();
// When
String greeting = app.getGreeting();
// Then
assertThat(greeting).isEqualTo("Hello World!");
}The project includes comprehensive code quality tools:
- Checkstyle: Enforces Google Java Style Guide
- PMD: Static analysis for potential issues
- SpotBugs: Bug pattern detection
- JaCoCo: Code coverage analysis (80% minimum coverage)
Run all quality checks:
./gradlew codeQualityThe GitHub Actions workflow includes:
- Multi-platform testing (Ubuntu, Windows, macOS)
- Multi-Java version testing (Java 17, 21)
- Code quality checks
- Test coverage reporting
- Dependency vulnerability scanning
- Build artifact generation
Key dependencies included:
- Testing: JUnit 5, AssertJ, Mockito
- Logging: SLF4J with Logback
- Utilities: Apache Commons Lang, Google Guava
- Kotlin: Standard library (for mixed projects)
Add new dependencies in build.gradle.kts:
dependencies {
implementation("group:artifact:version")
testImplementation("test-group:test-artifact:version")
}- Update package names in
build.gradle.kts - Move source files to new package structure
- Update imports and references
- Checkstyle: Edit
config/checkstyle/checkstyle.xml - PMD: Edit
config/pmd/ruleset.xml - SpotBugs: Edit
config/spotbugs/exclude.xml
Keep these files unchanged - they provide the template's core functionality:
π Configuration & Build
βββ build.gradle.kts β
Keep (modify project details only)
βββ settings.gradle.kts β
Keep (update project name)
βββ gradle.properties β
Keep (corporate network settings)
βββ gradlew / gradlew.bat β
Keep (Gradle wrapper)
βββ gradlew-corporate.* β
Keep (corporate network scripts)
βββ gradle/wrapper/ β
Keep (Gradle wrapper files)
π Code Quality & CI/CD
βββ .github/workflows/ci.yml β
Keep (CI/CD pipeline)
βββ .github/copilot-instructions.md β
Keep (GitHub Copilot config)
βββ config/checkstyle/ β
Keep (code quality rules)
βββ config/pmd/ β
Keep (static analysis)
βββ config/spotbugs/ β
Keep (bug detection)
βββ .gitignore β
Keep (Git ignore rules)
π Documentation
βββ CORPORATE-NETWORK-GUIDE.md β
Keep (troubleshooting guide)
βββ SETUP.md β
Keep (setup instructions)
βββ setup-corporate-network.* β
Keep (network setup scripts)
βββ LICENSE β
Keep (or update for your license)
Modify these files to match your specific project:
π Source Code - CUSTOMIZE
βββ src/main/java/com/example/gradle/
β βββ App.java π Replace with your main class
βββ src/test/java/com/example/gradle/
β βββ AppTest.java π Replace with your tests
βββ src/main/resources/
βββ logback.xml π Keep (modify logging config if needed)
π Documentation - CUSTOMIZE
βββ README.md π Update for your project
βββ .github/template-repository.json π Update template metadata
Delete these files after creating your project from the template:
π Template Cleanup - REMOVE
βββ .github/template-cleanup/
βββ README.md β Remove (template instructions only)
When using this template:
- Update project name in
settings.gradle.kts - Modify
build.gradle.ktsapplication details:- Change
application.mainClassfrom"com.example.gradle.App" - Update group name from
"com.example"
- Change
- Update repository name and description in this README
- Replace
src/main/java/com/example/gradle/with your package structure - Create your main application class (replace
App.java) - Replace example tests with your actual tests
- Update package imports throughout the codebase
- Customize this README for your project
- Update
SETUP.mdif you have specific setup requirements - Modify
.github/template-repository.jsonif creating another template - Update author information and license if needed
- Delete
.github/template-cleanup/directory - Remove template-specific sections from README
- Commit your customized project
- Test corporate network setup scripts work in your environment
- Verify
gradle.propertiessettings match your network requirements - Update
CORPORATE-NETWORK-GUIDE.mdwith environment-specific details
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and quality checks
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.