Skip to content

seregamorph/maven-surefire-cached

Repository files navigation

Maven Central Version License

Maven Surefire Cached

This extension wraps standard Maven surefire and failsafe plugins to support local and remote build caching.

Comparison with Maven Build Cache Extension

The Maven Build Cache Extension is an open-source project adding support of artifact caching to maven, also allowing to skip goal executions via cache. It can cover a wide range of typical scenarios, however, it's not a good choice for pipelines separating build and test phases. It does not properly handle test reports, does not support flexible test filtering (caching them separately depending on filtered test subset) for parallel execution. Also it does not cache so called CLI executions like mvn surefire:test, only lifecycle executions like mvn clean test, which is also not always convenient.

Adoption

Add to the or .mvn/extensions.xml of your project:

<extensions>
    <extension>
        <groupId>com.github.seregamorph</groupId>
        <artifactId>surefire-cached-extension</artifactId>
        <version>0.7</version>
    </extension>
</extensions>

This extension will print the cache statistics after the build.

Sample adoption:

First build without tests

mvn clean install -DskipTests=true

Then run unit tests

mvn surefire:test

Or via phase

mvn test

Then run integration tests

mvn failsafe:integration-test -Dit.test=SampleIT

or via phase

mvn verify

Using remote cache

mvn clean install -DcacheStorageUrl=http://localhost:8080/cache

How it works

The extension wraps and replaces default Mojo factory DefaultMavenPluginManager with own implementation CachedMavenPluginManager. All mojos are delegating to default behaviour except Surefire and Failsafe plugins. They are wrapped to caching logic, which calculates task inputs (classpath elements hash codes) and reuses existing cached test result when available.

Related projects

Turbo reactor

The default Maven multi-module build does not do an efficient multi-core CPU utilization. See turbo-builder for more details.

About

Maven surefire/failsafe plugins supporting build caching

Resources

License

Stars

Watchers

Forks

Packages

No packages published