Loading published curriculum…

05 · Your first Maven build / LESSON 18 OF 102

Maven and reproducible builds

Make a clean checkout build in a predictable way.

Before this lesson: JVM memory, thread safety, and virtual threads

Understand the topic

Maven reads pom.xml. Dependencies supply libraries; plugins perform build tasks. Java source goes in src/main/java, configuration in src/main/resources, and tests in src/test/java. Compilation, testing, and packaging are lifecycle stages.

Use the Maven Wrapper generated in the Spring project lesson. On Windows replace ./mvnw with .\mvnw.cmd. Commit wrapper files and ignore target/. These commands are a preview; run them after generating the project in lesson 13.

EXAMPLE · SHELL

Terminal · generated project root

./mvnw -v
./mvnw test
./mvnw clean verify
./mvnw dependency:tree

What to expect

Shows tool versions, runs tests, builds artifacts, and lists dependency relationships.

YOUR TURN

Put it into practice

  1. 01Find the source, resource, and test folders.
  2. 02Explain dependency versus plugin.
  3. 03Record the JDK version and build command in a README.

Pass a quiz or complete a lab to check today’s streak. Each lesson counts once per day, including when you review it later.

UNDER THE HOOD

Build the mental model

A build is a dependency graph of tasks and artifacts, not a collection of manual IDE actions.

  1. 01Maven resolves declared dependencies and their transitive dependencies. dependency:tree explains which version reached the classpath and through which parent.
  2. 02The wrapper selects Maven; the JDK is a separate choice. A successful IDE build does not prove the command-line JDK matches.
  3. 03test exercises tests before packaging; verify includes checks bound later in the lifecycle. Commit reproducible configuration, not generated target files.

A mistake worth avoiding

Avoid overriding framework-managed library versions without a compatibility reason.

DEBUGGING ROOM

Something broke. Where do you look?

A library works locally but fails on CI with NoSuchMethodError.

Before revealing the diagnosis, write down your first investigation step.

CHECK YOUR UNDERSTANDING

Does the Maven Wrapper also install the project JDK?

Choose one answer

BUILD IT YOURSELF

Create a reproducible build

  1. 1.Generate the project in the Boot setup lesson.
  2. 2.Run clean verify with the wrapper.
  3. 3.Document the JDK and inspect dependency:tree.

Acceptance checklist

Lab completion is your self-report. Knowledge checks do not certify project quality.

RETRIEVE IT FROM MEMORY

Why can runtime linkage fail even when your own code compiled?

Revisit this lesson in three days after a successful check or lab.

Ready for the next step?

Explain how a clean checkout produces a tested artifact.

Reading is separate from passing a knowledge check or completing a lab.

Go deeper · official references