Skip to content

Maven Build Cache

Avrea provides a cache endpoint for the Maven Build Cache Extension. Build outputs are cached so that modules with unchanged inputs skip recompilation.

The cache URL is pre-configured via MAVEN_OPTS:

Terminal window
MAVEN_OPTS="-Dmaven.build.cache.remote.url=http://avrea-host:8290/maven-build/cache \
-Dmaven.build.cache.remote.enabled=true \
-Dmaven.build.cache.remote.save.enabled=true"

You need to add the build cache extension to your project:

.mvn/extensions.xml
<!-- .mvn/extensions.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>org.apache.maven.extensions</groupId>
<artifactId>maven-build-cache-extension</artifactId>
<version>1.2.2</version>
</extension>
</extensions>
.mvn/maven-build-cache-config.xml
<!-- .mvn/maven-build-cache-config.xml -->
<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0">
<configuration>
<enabled>true</enabled>
<hashAlgorithm>SHA-256</hashAlgorithm>
<remote enabled="true" id="avrea-cache">
<url>http://avrea-host:8290/maven-build/cache</url>
</remote>
</configuration>
</cache>

The build cache extension is required regardless of runner environment.

Your workflow needs no changes:

workflow.yml
jobs:
build:
runs-on: avrea-ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
- run: mvn verify