Purpose & When-To-Use
Trigger conditions:
- Starting a new Java project requiring modern tooling
- Migrating legacy Java projects to contemporary best practices (Java 11+)
- Standardizing build configuration across multiple Java projects
- Setting up Spring Boot microservices with testing infrastructure
- Creating multi-module Maven/Gradle projects
Not for:
- Android projects (use
tooling-kotlin-generator instead)
- Legacy Java 8 projects (use framework-specific generators)
- Simple scripts without dependencies
Pre-Checks
Time normalization:
- Compute
NOW_ET using NIST/time.gov semantics (America/New_York, ISO-8601)
- Use
NOW_ET for all citation access dates
Input validation:
project_type must be one of: library, application, spring-boot, microservice
build_tool must be one of: maven, gradle
java_version must be one of: 11, 17, 21 (LTS versions)
project_name must be valid Java package name (lowercase, dots/hyphens allowed)
Source freshness:
Procedure
T1: Basic Project Structure (≤2k tokens)
Fast path for common cases:
Directory Layout Generation
Core Build Configuration
- Maven (pom.xml) accessed 2025-10-26
- Project metadata (groupId, artifactId, version)
- Java version configuration (maven.compiler.source/target)
- Basic dependencies (JUnit 5, logging)
- Gradle (build.gradle) accessed 2025-10-26
- Plugins: java-library, application
- Java toolchain configuration
- Dependency management
Basic .gitignore
- Build outputs (target/, build/, *.class)
- IDE files (.idea/, *.iml, .vscode/)
- OS files (.DS_Store)
Decision: If only basic scaffolding needed → STOP at T1; otherwise proceed to T2.
T2: Full Tooling Setup (≤6k tokens)
Extended configuration with testing and quality tools:
Testing Framework Configuration
JUnit 5 + Mockito accessed 2025-10-26
Maven dependencies:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
Gradle (build.gradle):
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testImplementation 'org.mockito:mockito-core:5.8.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.8.0'
}
test {
useJUnitPlatform()
}
Code Quality Tools
Checkstyle accessed 2025-10-26
- Maven plugin configuration
- Google Java Style or Sun checks
SpotBugs accessed 2025-10-26
- Static analysis for bug patterns
- Integration with Maven/Gradle
PMD (optional)
- Code quality rules
- Copy-paste detection (CPD)
Build Plugins
- maven-surefire-plugin (test execution)
- maven-failsafe-plugin (integration tests)
- jacoco-maven-plugin (code coverage)
- maven-enforcer-plugin (dependency convergence)
Spring Boot Configuration (if project_type == spring-boot)
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
</parent>
T3: Packaging and Distribution (≤12k tokens)
Deep configuration for production deployment:
JAR/WAR Packaging accessed 2025-10-26
- Executable JAR with manifest (Main-Class, Class-Path)
- Fat JAR with maven-shade-plugin or gradle shadow plugin
- WAR for servlet containers
Multi-Module Project Structure
- Parent POM with dependency management
- Module structure (api, core, service, integration-tests)
- Build reactor configuration
GraalVM Native Image accessed 2025-10-26
- native-maven-plugin configuration
- Reflection configuration (reflect-config.json)
- Resource configuration
- Build optimizations
Docker Packaging
- Multi-stage Dockerfile:
FROM maven:3.9-eclipse-temurin-21 AS build
WORKDIR /app
COPY pom.xml .
RUN mvn dependency:go-offline
COPY src src
RUN mvn package -DskipTests
FROM eclipse-temurin:21-jre-alpine
COPY --from=build /app/target/*.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
CI/CD Pipeline
- GitHub Actions workflow (build, test, package, deploy)
- Jenkins declarative pipeline
- SonarQube integration
- Artifact publishing (Maven Central, GitHub Packages)
TestContainers Integration (for integration tests)
@Testcontainers
class IntegrationTest {
@Container
static PostgreSQLContainer<?> postgres =
new PostgreSQLContainer<>("postgres:16-alpine");
}
Decision Rules
Build Tool Selection:
- Maven: Enterprise projects, strict dependency management, plugin ecosystem
- Gradle: Modern build performance, Kotlin DSL, flexible configuration
Project Type Structure:
- library: JAR packaging, no main class, extensive testing
- application: Executable JAR, main class, CLI or batch processing
- spring-boot: Spring Boot parent POM, auto-configuration, embedded server
- microservice: Spring Boot + Docker + health checks + observability
Abort Conditions:
- Invalid
project_name (contains spaces, uppercase, invalid chars) → error
- Unsupported
java_version (<11) → error "Minimum Java 11 required"
- Conflicting configuration (WAR + GraalVM) → error with alternatives
Tool Version Selection:
- Use latest stable LTS Java version (11, 17, 21)
- Pin test dependencies, use version ranges for compile deps (Maven)
- Use Gradle version catalog for multi-module projects
Output Contract
Schema (JSON):
{
"project_name": "string",
"project_type": "library | application | spring-boot | microservice",
"java_version": "string",
"build_tool": "maven | gradle",
"structure": {
"directories": ["string"],
"files": {
"path/to/file": "file content (string)"
}
},
"commands": {
"build": "string",
"test": "string",
"package": "string",
"run": "string (optional)"
},
"next_steps": ["string"],
"timestamp": "ISO-8601 string (NOW_ET)"
}
Required Fields:
project_name, project_type, java_version, build_tool, structure, commands, next_steps, timestamp
File Contents:
- All generated files must be syntactically valid (XML, Gradle, Java)
- Include inline comments explaining non-obvious configuration
- Reference official documentation in comments
Examples
Quick Start: Java Library (30 lines)
// examples/LibraryExample.java
package com.example.utils;
import java.time.Instant;
import java.util.*;
public final class StringMetrics {
public record Metrics(int length, int wordCount, Instant analyzed) {}
private final List<String> history = new ArrayList<>();
public Metrics analyze(String text) {
if (text == null || text.isBlank()) {
throw new IllegalArgumentException("Text cannot be null or blank");
}
history.add(text);
int wordCount = text.split("\\s+").length;
return new Metrics(text.length(), wordCount, Instant.now());
}
public List<String> getHistory() {
return Collections.unmodifiableList(history);
}
}
Additional Examples:
- CLI Tool:
examples/CliExample.java (30 lines) - picocli, file I/O, exit codes
- Spring Boot API:
examples/ApiExample.java (36 lines) - REST endpoints, records, concurrent storage
Template Resources (see resources/)
- Maven:
pom-library.xml / pom-cli.xml / pom-springboot.xml
- Gradle:
build-library.gradle / build-cli.gradle / build-springboot.gradle
- Testing:
ExampleTest.java - JUnit 5 with modern assertions
Quality Gates
Token Budgets:
- T1: ≤2k tokens (basic structure + core build config)
- T2: ≤6k tokens (full tooling: testing, quality, Spring Boot)
- T3: ≤12k tokens (packaging, multi-module, native-image, CI/CD)
Safety:
- No hardcoded credentials or API keys
- .gitignore always includes sensitive file patterns
- Docker images use non-root users
Auditability:
- All tool configurations cite official documentation
- Version constraints are explicit (no floating versions)
- Generated files include generation timestamp and tool versions
Determinism:
- Same inputs → identical file structure and configuration
- Tool versions pinned to specific releases
- No randomness in file generation
Performance:
- T1 generation: <1 second
- T2 generation: <3 seconds (includes all configs)
- T3 generation: <5 seconds (includes Docker, CI/CD)
Resources
Official Documentation (accessed 2025-10-26):
- Maven Documentation - Build tool and POM reference
- Gradle User Guide - Build automation
- JUnit 5 User Guide - Testing framework
- Spring Boot Documentation - Framework reference
- GraalVM Native Image - Native compilation
- Checkstyle - Code style checking
- SpotBugs - Static analysis
- Testcontainers - Integration testing
Build Tools:
Best Practices:
1---2name: java-tooling-specialist3description: Generate Java project scaffolding with Maven/Gradle, JUnit 5, Mockito, Checkstyle/SpotBugs, and packaging (JAR/WAR/native-image).4license: MIT5---67## Purpose & When-To-Use89**Trigger conditions:**10- Starting a new Java project requiring modern tooling11- Migrating legacy Java projects to contemporary best practices (Java 11+)12- Standardizing build configuration across multiple Java projects13- Setting up Spring Boot microservices with testing infrastructure14- Creating multi-module Maven/Gradle projects1516**Not for:**17- Android projects (use `tooling-kotlin-generator` instead)18- Legacy Java 8 projects (use framework-specific generators)19- Simple scripts without dependencies2021---2223## Pre-Checks2425**Time normalization:**26- Compute `NOW_ET` using NIST/time.gov semantics (America/New_York, ISO-8601)27- Use `NOW_ET` for all citation access dates2829**Input validation:**30- `project_type` must be one of: library, application, spring-boot, microservice31- `build_tool` must be one of: maven, gradle32- `java_version` must be one of: 11, 17, 21 (LTS versions)33- `project_name` must be valid Java package name (lowercase, dots/hyphens allowed)3435**Source freshness:**36- Maven docs must be accessible [accessed 2025-10-26](https://maven.apache.org/guides/)37- Gradle docs must be accessible [accessed 2025-10-26](https://docs.gradle.org/)38- JUnit 5 docs must be accessible [accessed 2025-10-26](https://junit.org/junit5/)39- Spring Boot docs must be accessible [accessed 2025-10-26](https://spring.io/projects/spring-boot)4041---4243## Procedure4445### T1: Basic Project Structure (≤2k tokens)4647**Fast path for common cases:**48491. **Directory Layout Generation**50 - Maven standard directory structure:51 ```52 project-name/53 src/54 main/55 java/com/example/project/56 resources/57 test/58 java/com/example/project/59 resources/60 pom.xml (Maven) or build.gradle (Gradle)61 README.md62 .gitignore63 ```64652. **Core Build Configuration**66 - **Maven (pom.xml)** [accessed 2025-10-26](https://maven.apache.org/pom.html)67 - Project metadata (groupId, artifactId, version)68 - Java version configuration (maven.compiler.source/target)69 - Basic dependencies (JUnit 5, logging)70 - **Gradle (build.gradle)** [accessed 2025-10-26](https://docs.gradle.org/current/samples/sample_building_java_libraries.html)71 - Plugins: java-library, application72 - Java toolchain configuration73 - Dependency management74753. **Basic .gitignore**76 - Build outputs (target/, build/, *.class)77 - IDE files (.idea/, *.iml, .vscode/)78 - OS files (.DS_Store)7980**Decision:** If only basic scaffolding needed → STOP at T1; otherwise proceed to T2.8182---8384### T2: Full Tooling Setup (≤6k tokens)8586**Extended configuration with testing and quality tools:**87881. **Testing Framework Configuration**8990 **JUnit 5 + Mockito** [accessed 2025-10-26](https://junit.org/junit5/docs/current/user-guide/)9192 Maven dependencies:93 ```xml94 <dependency>95 <groupId>org.junit.jupiter</groupId>96 <artifactId>junit-jupiter</artifactId>97 <version>5.10.1</version>98 <scope>test</scope>99 </dependency>100 <dependency>101 <groupId>org.mockito</groupId>102 <artifactId>mockito-core</artifactId>103 <version>5.8.0</version>104 <scope>test</scope>105 </dependency>106 <dependency>107 <groupId>org.mockito</groupId>108 <artifactId>mockito-junit-jupiter</artifactId>109 <version>5.8.0</version>110 <scope>test</scope>111 </dependency>112 ```113114 Gradle (build.gradle):115 ```gradle116 dependencies {117 testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'118 testImplementation 'org.mockito:mockito-core:5.8.0'119 testImplementation 'org.mockito:mockito-junit-jupiter:5.8.0'120 }121122 test {123 useJUnitPlatform()124 }125 ```1261272. **Code Quality Tools**128129 **Checkstyle** [accessed 2025-10-26](https://checkstyle.sourceforge.io/)130 - Maven plugin configuration131 - Google Java Style or Sun checks132133 **SpotBugs** [accessed 2025-10-26](https://spotbugs.github.io/)134 - Static analysis for bug patterns135 - Integration with Maven/Gradle136137 **PMD** (optional)138 - Code quality rules139 - Copy-paste detection (CPD)1401413. **Build Plugins**142 - maven-surefire-plugin (test execution)143 - maven-failsafe-plugin (integration tests)144 - jacoco-maven-plugin (code coverage)145 - maven-enforcer-plugin (dependency convergence)1461474. **Spring Boot Configuration** (if `project_type == spring-boot`)148 ```xml149 <parent>150 <groupId>org.springframework.boot</groupId>151 <artifactId>spring-boot-starter-parent</artifactId>152 <version>3.2.0</version>153 </parent>154 ```155156---157158### T3: Packaging and Distribution (≤12k tokens)159160**Deep configuration for production deployment:**1611621. **JAR/WAR Packaging** [accessed 2025-10-26](https://maven.apache.org/plugins/maven-jar-plugin/)163 - Executable JAR with manifest (Main-Class, Class-Path)164 - Fat JAR with maven-shade-plugin or gradle shadow plugin165 - WAR for servlet containers1661672. **Multi-Module Project Structure**168 - Parent POM with dependency management169 - Module structure (api, core, service, integration-tests)170 - Build reactor configuration1711723. **GraalVM Native Image** [accessed 2025-10-26](https://www.graalvm.org/latest/reference-manual/native-image/)173 - native-maven-plugin configuration174 - Reflection configuration (reflect-config.json)175 - Resource configuration176 - Build optimizations1771784. **Docker Packaging**179 - Multi-stage Dockerfile:180 ```dockerfile181 FROM maven:3.9-eclipse-temurin-21 AS build182 WORKDIR /app183 COPY pom.xml .184 RUN mvn dependency:go-offline185 COPY src src186 RUN mvn package -DskipTests187188 FROM eclipse-temurin:21-jre-alpine189 COPY --from=build /app/target/*.jar app.jar190 ENTRYPOINT ["java", "-jar", "/app.jar"]191 ```1921935. **CI/CD Pipeline**194 - GitHub Actions workflow (build, test, package, deploy)195 - Jenkins declarative pipeline196 - SonarQube integration197 - Artifact publishing (Maven Central, GitHub Packages)1981996. **TestContainers Integration** (for integration tests)200 ```java201 @Testcontainers202 class IntegrationTest {203 @Container204 static PostgreSQLContainer<?> postgres =205 new PostgreSQLContainer<>("postgres:16-alpine");206 }207 ```208209---210211## Decision Rules212213**Build Tool Selection:**214- **Maven:** Enterprise projects, strict dependency management, plugin ecosystem215- **Gradle:** Modern build performance, Kotlin DSL, flexible configuration216217**Project Type Structure:**218- **library:** JAR packaging, no main class, extensive testing219- **application:** Executable JAR, main class, CLI or batch processing220- **spring-boot:** Spring Boot parent POM, auto-configuration, embedded server221- **microservice:** Spring Boot + Docker + health checks + observability222223**Abort Conditions:**224- Invalid `project_name` (contains spaces, uppercase, invalid chars) → error225- Unsupported `java_version` (<11) → error "Minimum Java 11 required"226- Conflicting configuration (WAR + GraalVM) → error with alternatives227228**Tool Version Selection:**229- Use latest stable LTS Java version (11, 17, 21)230- Pin test dependencies, use version ranges for compile deps (Maven)231- Use Gradle version catalog for multi-module projects232233---234235## Output Contract236237**Schema (JSON):**238239```json240{241 "project_name": "string",242 "project_type": "library | application | spring-boot | microservice",243 "java_version": "string",244 "build_tool": "maven | gradle",245 "structure": {246 "directories": ["string"],247 "files": {248 "path/to/file": "file content (string)"249 }250 },251 "commands": {252 "build": "string",253 "test": "string",254 "package": "string",255 "run": "string (optional)"256 },257 "next_steps": ["string"],258 "timestamp": "ISO-8601 string (NOW_ET)"259}260```261262**Required Fields:**263- `project_name`, `project_type`, `java_version`, `build_tool`, `structure`, `commands`, `next_steps`, `timestamp`264265**File Contents:**266- All generated files must be syntactically valid (XML, Gradle, Java)267- Include inline comments explaining non-obvious configuration268- Reference official documentation in comments269270---271272## Examples273274**Quick Start: Java Library** (30 lines)275276```java277// examples/LibraryExample.java278package com.example.utils;279280import java.time.Instant;281import java.util.*;282283public final class StringMetrics {284 public record Metrics(int length, int wordCount, Instant analyzed) {}285286 private final List<String> history = new ArrayList<>();287288 public Metrics analyze(String text) {289 if (text == null || text.isBlank()) {290 throw new IllegalArgumentException("Text cannot be null or blank");291 }292 history.add(text);293 int wordCount = text.split("\\s+").length;294 return new Metrics(text.length(), wordCount, Instant.now());295 }296297 public List<String> getHistory() {298 return Collections.unmodifiableList(history);299 }300}301```302303**Additional Examples:**304- **CLI Tool**: `examples/CliExample.java` (30 lines) - picocli, file I/O, exit codes305- **Spring Boot API**: `examples/ApiExample.java` (36 lines) - REST endpoints, records, concurrent storage306307**Template Resources** (see `resources/`)308- Maven: `pom-library.xml` / `pom-cli.xml` / `pom-springboot.xml`309- Gradle: `build-library.gradle` / `build-cli.gradle` / `build-springboot.gradle`310- Testing: `ExampleTest.java` - JUnit 5 with modern assertions311312---313314## Quality Gates315316**Token Budgets:**317- **T1:** ≤2k tokens (basic structure + core build config)318- **T2:** ≤6k tokens (full tooling: testing, quality, Spring Boot)319- **T3:** ≤12k tokens (packaging, multi-module, native-image, CI/CD)320321**Safety:**322- No hardcoded credentials or API keys323- .gitignore always includes sensitive file patterns324- Docker images use non-root users325326**Auditability:**327- All tool configurations cite official documentation328- Version constraints are explicit (no floating versions)329- Generated files include generation timestamp and tool versions330331**Determinism:**332- Same inputs → identical file structure and configuration333- Tool versions pinned to specific releases334- No randomness in file generation335336**Performance:**337- T1 generation: <1 second338- T2 generation: <3 seconds (includes all configs)339- T3 generation: <5 seconds (includes Docker, CI/CD)340341---342343## Resources344345**Official Documentation (accessed 2025-10-26):**3461. [Maven Documentation](https://maven.apache.org/guides/) - Build tool and POM reference3472. [Gradle User Guide](https://docs.gradle.org/current/userguide/userguide.html) - Build automation3483. [JUnit 5 User Guide](https://junit.org/junit5/docs/current/user-guide/) - Testing framework3494. [Spring Boot Documentation](https://spring.io/projects/spring-boot) - Framework reference3505. [GraalVM Native Image](https://www.graalvm.org/latest/reference-manual/native-image/) - Native compilation3516. [Checkstyle](https://checkstyle.sourceforge.io/) - Code style checking3527. [SpotBugs](https://spotbugs.github.io/) - Static analysis3538. [Testcontainers](https://testcontainers.com/) - Integration testing354355**Build Tools:**356- [Maven Central Repository](https://search.maven.org/) - Dependency search357- [Gradle Plugin Portal](https://plugins.gradle.org/) - Gradle plugins358- [Maven Wrapper](https://maven.apache.org/wrapper/) - Portable builds359- [Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) - Version management360361**Best Practices:**362- [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html) - Code formatting363- [Effective Java (3rd Edition)](https://www.oreilly.com/library/view/effective-java/9780134686097/) - Best practices364- [Spring Boot Best Practices](https://spring.io/guides/tutorials/rest/) - Framework patterns