Checkout all the free Maven, Gradle, and DPE courses at the DPE University!
This is a hands-on exercise to go along with the Maven Build Cache Deep Dive training module. In this exercise you will go over the following:
- How to deal with cache misses.
The sample code represents a multi-module build. The module build-info
generates a file build-info.properties
containing the current timestamp and the project version. The module application
uses the artifact produced by build-info
.
- Finished going through the Troubleshooting Build Cache Misses section in Maven Build Cache Deep Dive.
- Java 11+
- If you have not completed the previous labs, authenticate Maven with the Develocity server.
Note
As part of taking this free course, you have access to a training instance of Develocity located at:
https://dpeuniversity-develocity.gradle.com/
Sign in to this Develocity server using the same account you use for the DPE University.
This server is configured so users can only access the Build Scan® and Build Cache entries they publish.
Run the following command and follow the instructions in your terminal:
./mvnw com.gradle:develocity-maven-extension:provision-access-key
Note
For more ways to authenticate, see the authentication guide to see how to provide credentials.
-
Notice how the
model
build produces abuild-info.properties
(filtered fromsrc/main/resources
). -
In
application/pom.xml
notice thatbuild-info
is a dependency for theapplication
module. -
Execute the build multiple times and identify the reason why the test goal needs to execute every time with the help of the "Build Comparison" tool in Develocity:
./mvnw clean install
-
Configure the Build Scan to capture the goal inputs.
Important
This is now enabled by default, continue to the next step!
This step remains in the readme because the corresponding course video mentions it.
- Normalize the runtime classpath to ignore unstable input files.
See the ignoring arbitrary files guide to see how to normalize the
build-info.properties
file from the runtime classpath.
Note
The normalization
element is a direct child of the develocity
element.
-
Execute the build again, at least twice. Verify that there are build cache hits by looking at the Build Scan. Furthermore, check for differences in the build comparison view.
./mvnw clean install
Important
Instead if ignoring an entire file, you can instead ignore specific properties. See the free build cache course for a detailed walk through.
To see the solution to the lab, check out the solution
branch of this project.
Be sure to check out our other free courses and labs!
Related courses:
- Maven - Build Cache Deep Dive
- Maven - Maintaining an Optimized Build Cache
- Develocity - How to Use Build Scans
Related labs: