Template Features
Everything you need for modern Java 25 development with best practices built-in
Java 25 Ready
This template is built specifically for Java 25, taking advantage of the latest language features and improvements.
Compiler Configuration
<maven.compiler.release>25</maven.compiler.release>
Uses the latest Java 25 compiler release setting for optimal compatibility and feature access.
CI/CD Integration
- name: "Setup JDK"
uses: actions/setup-java@v5
with:
distribution: "oracle"
java-version: 25
GitHub Actions workflow configured with Oracle JDK 25 for consistent builds and deployments.
Java Preview Features Enabled
Experience cutting-edge Java features before they become standard. Preview features are enabled across compilation and test execution for early adoption and experimentation.
Compiler Configuration
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
<configuration>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
Enables preview features during compilation for access to experimental Java language enhancements.
Test Execution Support
<!-- Surefire (unit tests) -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
<!-- Failsafe (integration tests) -->
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
Both unit and integration tests can leverage preview features with consistent configuration across all test runners.
โน๏ธ What are Preview Features?
Preview features are fully implemented Java language or JVM features that are not yet permanent. They allow developers to provide feedback before features become standard in future releases. Preview features are production-quality but may undergo changes based on community feedback.
Examples: Pattern matching enhancements, structured concurrency, virtual threads improvements, and other experimental APIs.
Testing Excellence
Comprehensive testing setup with separation of concerns and modern testing libraries.
Separated Test Execution
Surefire Plugin for unit tests (*Test.java) and Failsafe Plugin for integration tests (*IT.java) with different execution phases.
Parallel Test Execution
JUnit Platform configured for parallel test execution with dynamic strategy for faster feedback loops.
Property-Based Testing
jqwik 1.9.3 for property-based testing to discover edge cases automatically with generated test data.
Architecture Testing
ArchUnit 1.4.1 for testing architectural rules and ensuring code structure compliance.
Fluent Assertions
AssertJ 3.27.6 for readable and maintainable test assertions with fluent API.
Test Data Generation
Instancio 5.5.1 for generating test data objects automatically with customizable constraints.
Parallel Test Configuration
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.config.strategy = dynamic
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent
Code Quality & Formatting
Automated code quality enforcement with industry-standard formatting and best practices.
Spotless Code Formatting
Google Java Format with AOSP style automatically applied during compilation phase.
./mvnw spotless:apply # Format code
./mvnw spotless:check # Verify formatting
Automated Quality Gates
Spotless formatting checks run automatically during the compile phase to ensure consistent code style.
<execution>
<goals><goal>check</goal></goals>
<phase>compile</phase>
</execution>
Maven Configuration & Best Practices
Optimized Maven configuration with wrapper for consistent builds across environments.
Maven Wrapper
No need to install Maven locally. The wrapper ensures consistent Maven version across all environments.
JVM Configuration
Optimized JVM settings in .mvn/jvm.config for better performance and headless operation.
Maven Optimizations
Batch mode, fail-at-end, and no transfer progress for cleaner CI/CD output.
Maven Extensions
OpenTelemetry tracing and build cache extensions for enhanced observability and performance.
Configuration Files
.mvn/jvm.config
-Xmx2048m -Xms512m -Djava.awt.headless=true
Optimized heap settings and headless mode for CI environments.
.mvn/maven.config
-B
--fail-at-end
--no-transfer-progress
Batch mode and optimization flags for better CI/CD experience.
Build Performance & Observability
Enhanced build pipeline with distributed tracing and intelligent caching for faster builds and better insights into build performance.
OpenTelemetry Maven Extension
Version 1.50.0-alpha - Distributed tracing for Maven builds with deep observability into build performance, plugin execution, and bottleneck identification.
Maven Build Cache Extension
Version 1.2.0 - Intelligent build caching that reuses previous build results to dramatically reduce build times for unchanged modules.
Extensions Configuration
Extensions are configured in .mvn/extensions.xml and automatically activated for all Maven builds.
<extensions>
<extension>
<groupId>org.apache.maven.extensions</groupId>
<artifactId>maven-build-cache-extension</artifactId>
<version>1.2.0</version>
</extension>
<extension>
<groupId>io.opentelemetry.contrib</groupId>
<artifactId>opentelemetry-maven-extension</artifactId>
<version>1.50.0-alpha</version>
</extension>
</extensions>
๐ Build Observability Benefits
- Trace Execution: Monitor build phases and plugin execution in real-time
- Performance Insights: Identify slow plugins and optimization opportunities
- Export Options: Send traces to Jaeger, Zipkin, or OTLP-compatible collectors
- CI/CD Monitoring: Track build health and performance trends over time
- Debugging: Detailed spans for troubleshooting build failures
โก Build Cache Benefits
- Incremental Builds: Only rebuild modules that have changed
- Time Savings: Reduce build times by 40-70% in typical scenarios
- Local Cache: Reuse outputs from previous local builds
- Remote Cache: Share build cache across team members (configurable)
- Smart Detection: Automatic cache invalidation when dependencies change
- CI/CD Optimization: Dramatically faster pipeline execution
๐ก Getting Started with Extensions
Build Cache: Works automatically out of the box. Clean builds create cache entries, subsequent builds reuse them. Use ./mvnw clean verify to populate the cache.
OpenTelemetry: Requires environment configuration to export traces. Set OTEL_EXPORTER_OTLP_ENDPOINT to your collector URL, or traces will be logged locally. Perfect for local development insights even without a collector.
Development Tools
Modern development tools and integrations for enhanced productivity.
JShell Integration
REPL development support with JShell Maven plugin for interactive Java development and experimentation.
./mvnw jshell:run
Modularization Ready
Java Platform Module System (JPMS) configured with module-info.java files for both main and test sources.
jenv Configuration
Java version management with jenv for easy switching between different Java versions in development.
Fat JAR Support
Maven Shade plugin available via profile for creating executable JAR files with all dependencies.
./mvnw package -Pshade
CI/CD & Automation
GitHub Actions workflow ready for continuous integration and deployment.
GitHub Actions Workflow
name: Maven Build
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: "Setup JDK"
uses: actions/setup-java@v5
with:
distribution: "oracle"
java-version: 25
cache: "maven"
- name: "Build with Maven"
run: ./mvnw verify
Complete CI/CD pipeline with Oracle JDK 25, Maven caching, and full verification including tests and quality checks.
Ready to Use All These Features?
Start your Java 25 project with all these best practices and tools pre-configured.