---
name: configuring-java-stack
description: Java stack configuration - Maven, JUnit 5, Spotless, SpotBugs, JaCoCo with 96% coverage threshold
---
# Java Stack
## Standards Compliance
| Standard | Level | Status |
|----------|-------|--------|
| aug-just/justfile-interface | Baseline (Level 0) | ✓ Full |
| development-stack-standards | Level 2 | ✓ Complete |
**Dimensions:** 11/13 (Foundation + Quality Gates + Security)
## Toolchain
| Tool | Use |
|------|-----|
| **Maven** | Build & dependency management |
| **Java 21** | Language (LTS) |
| **JUnit 5** | Testing framework |
| **Spotless** | Code formatter (Google Java Format) |
| **SpotBugs** | Static analysis / linting |
| **JaCoCo** | Code coverage (96% threshold) |
| **Checkstyle** | Basic complexity check |
| **PMD** | Detailed complexity analysis |
| **cloc** | Lines of code counter |
## Stack Dimensions
| Dimension | Tool | Level |
|-----------|------|-------|
| Package manager | Maven | 0 |
| Format | Spotless + Google Java Format | 0 |
| Lint | SpotBugs | 0 |
| Typecheck | javac | 0 |
| Test | JUnit 5 | 0 |
| Coverage | JaCoCo (96%) | 1 |
| Complexity | Checkstyle (≤10) | 1 |
| Test watch | fizzed-watcher | 1 |
| LOC | cloc | 1 |
| Deps | versions:display-dependency-updates | 2 |
| Vulns | dependency-check | 2 |
| License | license:add-third-party | 2 |
| SBOM | cyclonedx-maven-plugin | 2 |
## Quick Reference
```bash
mvn clean install -DskipTests
mvn spotless:apply
mvn spotbugs:check checkstyle:check
mvn compile
mvn test -Dgroups="!integration"
mvn clean verify -Dgroups="!integration"
```
## Docker Compatibility
Web services: Bind to `0.0.0.0` (not `127.0.0.1`)
```properties
# application.properties
server.address=0.0.0.0
server.port=${PORT:8080}
```
## Standard Justfile Interface
**Implements:** aug-just/justfile-interface (Level 0 baseline)
**Requires:** aug-just plugin for justfile management
```just
set shell := ["bash", "-uc"]
# Show all available commands
default:
@just --list
# Install dependencies and setup development environment
dev-install:
mvn clean install -DskipTests
# Format code (auto-fix)
format:
mvn spotless:apply
# Lint code (auto-fix, complexity threshold=10)
lint:
mvn spotbugs:check checkstyle:check
# Type check code
typecheck:
mvn clean compile
# Run unit tests
test:
mvn test -Dgroups="!integration"
# Run tests in watch mode
test-watch:
mvn fizzed-watcher:run
# Run unit tests with coverage threshold (96%)
coverage:
mvn clean verify -Dgroups="!integration" -Djacoco.haltOnFailure=true
# Run integration tests with coverage report (no threshold)
integration-test:
mvn verify -Dgroups="integration"
# Detailed complexity report for refactoring decisions
complexity:
mvn pmd:pmd
# Show N largest files by lines of code
loc N="20":
@echo "📊 Top {{N}} largest files by LOC:"
@cloc src/ --by-file --include-lang=Java --quiet | sort -rn | head -{{N}}
# Show outdated packages
deps:
mvn versions:display-dependency-updates
# Check for security vulnerabilities
vulns:
mvn dependency-check:check
# Analyze licenses (flag GPL, etc.)
lic:
mvn license:add-third-party
# Generate software bill of materials
sbom:
mvn org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom
# Build artifacts
build:
mvn clean package
# Run all quality checks (format, lint, typecheck, coverage - fastest first)
check-all: format lint typecheck coverage
@echo "✅ All checks passed"
# Remove generated files and artifacts
clean:
mvn clean
```
## pom.xml Configuration
**Key plugins:**
```xml
21
21
UTF-8
org.junit.jupiter
junit-jupiter
5.10.1
test
com.diffplug.spotless
spotless-maven-plugin
2.43.0
1.19.2
com.github.spotbugs
spotbugs-maven-plugin
4.8.3.0
Max
Low
true
org.jacoco
jacoco-maven-plugin
0.8.11
check
check
LINE
COVEREDRATIO
0.96
org.apache.maven.plugins
maven-checkstyle-plugin
3.3.1
google_checks.xml
true
```
## Notes
- Tag integration tests: `@Tag("integration")` (JUnit 5)
- Unit tests (untagged) run in check-all with 96% threshold
- Treat compiler warnings as errors: `-Xlint:all -Werror`