Loading published curriculum…

06 · Maven from first build to release / LESSON 19 OF 102

POM structure, coordinates, and project layout

The POM is the reproducible description of your project, not a list of IDE settings.

Before this lesson: Maven and reproducible builds

Understand the topic

groupId, artifactId, and version identify an artifact. src/main/java contains application sources, src/main/resources runtime resources, and src/test/java test sources. target contains generated build output and belongs in .gitignore.

A parent can provide shared configuration. Properties centralize values such as the Java release. Keep the Maven Wrapper in version control so a clean checkout uses a known Maven distribution. Windows users run mvnw.cmd; Unix shells use ./mvnw.

EXAMPLE · XML

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>task-domain</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <properties>
    <maven.compiler.release>21</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
</project>

What to expect

A minimal model for a Java library. Pin build-plugin versions before treating it as a release build.

YOUR TURN

Put it into practice

  1. 01Create a task-domain Maven project.
  2. 02Move a plain Java example into src/main/java and run the build outside the IDE.
  3. 03Verify: A clean checkout compiles using the wrapper and generated target files are ignored.

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

The POM is the reproducible description of your project, not a list of IDE settings.

  1. 01groupId, artifactId, and version identify an artifact. src/main/java contains application sources, src/main/resources runtime resources, and src/test/java test sources. target contains generated build output and belongs in .gitignore.
  2. 02A parent can provide shared configuration. Properties centralize values such as the Java release. Keep the Maven Wrapper in version control so a clean checkout uses a known Maven distribution. Windows users run mvnw.cmd; Unix shells use ./mvnw.
  3. 03Trace the example: A minimal model for a Java library. Pin build-plugin versions before treating it as a release build.

A mistake worth avoiding

Maven reports no sources while the IDE can run the class.

DEBUGGING ROOM

Something broke. Where do you look?

Maven reports no sources while the IDE can run the class.

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

CHECK YOUR UNDERSTANDING

Which directory normally contains generated Maven artifacts?

Choose one answer

BUILD IT YOURSELF

Create a task-domain Maven project.

  1. 1.Create a task-domain Maven project.
  2. 2.Move a plain Java example into src/main/java and run the build outside the IDE.
  3. 3.Reproduce this failure, then repair it: Maven reports no sources while the IDE can run the class.

Acceptance checklist

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

RETRIEVE IT FROM MEMORY

Which directory normally contains generated Maven artifacts?

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

Ready for the next step?

A clean checkout compiles using the wrapper and generated target files are ignored.

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

Go deeper · official references