Java Build Tooling¶
Status: 🟢 Active | Owner: Java Guild
Approved Build Tools¶
| Tool | Status | Use Case |
|---|---|---|
| Gradle 8.x | ✅ Preferred | New services and multi-module projects |
| Maven 3.9.x | ✅ Supported | Existing Maven projects; acceptable for new libraries |
| Ant | ❌ Not approved | Legacy only |
| Bazel | ⚠️ Evaluate | Large monorepos — Architecture approval required |
Gradle is the preferred tool for new projects due to its build caching, incremental compilation, and Kotlin DSL support.
Gradle Configuration¶
All projects must use the Kotlin DSL (build.gradle.kts) for new Gradle projects:
// build.gradle.kts
plugins {
java
id("org.springframework.boot") version "3.2.5"
id("io.spring.dependency-management") version "1.1.4"
}
group = "com.acme.orders"
version = "1.0.0"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
Wrapper Requirement¶
All projects must include and commit the Gradle or Maven wrapper:
# Gradle
gradle wrapper --gradle-version 8.7
git add gradle/ gradlew gradlew.bat
# Maven
mvn wrapper:wrapper -Dmaven=3.9.6
git add .mvn/ mvnw mvnw.cmd
CI always invokes the wrapper (./gradlew, ./mvnw) — never uses a globally installed version.
Build Caching¶
Enable Gradle remote build cache in CI to dramatically reduce build times:
// settings.gradle.kts
buildCache {
remote<HttpBuildCache> {
url = uri("https://build-cache.acme.internal/cache/")
credentials {
username = providers.environmentVariable("BUILD_CACHE_USER").get()
password = providers.environmentVariable("BUILD_CACHE_TOKEN").get()
}
push = System.getenv("CI") == "true"
}
}
Standard Gradle Tasks¶
| Task | Purpose |
|---|---|
./gradlew build | Compile, test, assemble JAR |
./gradlew test | Run unit tests only |
./gradlew integrationTest | Run integration tests |
./gradlew bootJar | Build executable Spring Boot JAR |
./gradlew dependencyUpdates | Check for dependency updates |
./gradlew check | All verification tasks (tests + linting) |
Multi-Module Projects¶
For multi-module projects, define shared configuration in the root build.gradle.kts:
// root build.gradle.kts
subprojects {
apply(plugin = "java")
apply(plugin = "checkstyle")
repositories { mavenCentral() }
tasks.withType<Test> {
useJUnitPlatform()
jvmArgs("-Xmx512m")
}
}
References¶
Last reviewed: 2025-Q4 | Owner: Java Guild