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:
- What happens when not all the inputs used by a goal are defined.
- How to define additional inputs to the build cache.
- Finished going through the Inputs and Outputs section in Maven Build Cache Deep Dive.
- Java 11+
-
View the
pom.xml
, pay attention to themaven-surefire-plugin
configuration and how theINTEGRATION_TEST_SAMPLES
environment variable is used inApplicationStartupTest.java
-
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.
-
Enable the build cache debug logging to view additional details:
export MAVEN_OPTS="-Dorg.slf4j.simpleLogger.log.develocity.goal.cache=debug"
-
Execute the following command multiple times:
./mvnw clean verify
-
Open the Build Scan and look at the Performance -> Goal execution tab. Can you identify the goals that came
FROM-CACHE
? -
Change the first line in one of the files under
src/integration-test-samples
so that the assertions in the test case isn't met anymore. Execute the build again. (Does the test fail?)./mvnw clean verify
-
Add an input for the
maven-surefire-plugin
so that the files undersrc/integration-test-samples
are considered. Execute the build again, does the test fail?./mvnw clean verify
See the declaring additional inputs guide to see how to add the
src/integration-test-samples
as an input to the test task. -
Run the build again and see if the tests fail now:
./mvnw clean verify
-
Fix (or revert) the input files so that the test passes, run the build again:
./mvnw clean verify
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: