Skip to content

gradle/dpeuni-maven-build-cache-deep-dive-missing-inputs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DPE University Training

Checkout all the free Maven, Gradle, and DPE courses at the DPE University!

Maven Build Cache Deep Dive - Lab 02: Missing Inputs With Build Caching

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.

Prerequisites

  • Finished going through the Inputs and Outputs section in Maven Build Cache Deep Dive.
  • Java 11+

Steps

  1. View the pom.xml, pay attention to the maven-surefire-plugin configuration and how the INTEGRATION_TEST_SAMPLES environment variable is used in ApplicationStartupTest.java

  2. 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:gradle-enterprise-maven-extension:provision-access-key

Note

For more ways to authenticate, see the authentication guide to see how to provide credentials.

  1. Enable the build cache debug logging to view additional details:

    export MAVEN_OPTS="-Dorg.slf4j.simpleLogger.log.gradle.goal.cache=debug"
  2. Execute the following command multiple times:

     ./mvnw clean verify
  3. Open the Build Scan and look at the Performance -> Goal execution tab. Can you identify the goals that came FROM-CACHE?

  4. 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
  5. Add an input for the maven-surefire-plugin so that the files under src/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.

  6. Run the build again and see if the tests fail now:

    ./mvnw clean verify
  7. Fix (or revert) the input files so that the test passes, run the build again:

    ./mvnw clean verify

Solution Reference

To see the solution to the lab, check out the solution branch of this project.

More Free Labs & Courses

Be sure to check out our other free courses and labs!

Related courses:

Related labs: