Normal usage
Once the extension is activated, the cache automatically kicks in on every package
or higher phase.
Subtree builds
The build could be invoked on any module in the project and will try to discover the cache by introspecting dependencies. In order to identify which dependencies are cacheable, the cache introspects the following:
- Project root location passed with
-Dmaven.multiModuleProjectDirectory
- Profiles that activate full graph in the project build. The cache uses this
full
mode to categorize project modules as cacheable or not:
<configuration>
...
<multiModule>
<discovery>
<scanProfiles>
<scanProfile>my-full-project-profile</scanProfile>
</scanProfiles>
</discovery>
</multiModule>
...
</configuration>
Disable cache
Disable in config:
<cache>
<configuration>
<enabled>false</enabled>
</configuration>
</cache>
On the command line:
-Dmaven.build.cache.enabled=false
When a configuration is disabled by default in the config, it can be enabled via the command line with:
-Dmaven.build.cache.enabled=true
IDE support
Build cache extension is generally compatible with IDEs with one limitation:
- The cache doesn't restore the entire project state. Compiled classes, unpacked artifacts, and similar ones typically
will not be restored in the build directory (aka
target
). Configure your IDE to not use Maven build (target
) directories for compilation and execution. In that case, IDE will provide fast compilation using native caches, and the build cache will supplement that with fast builds.