Fundamentals 10 min read

What’s New in Maven 4? Model Upgrade, Flattened POMs, and Parallel Builds

Maven 4, released at the end of 2025, introduces a 4.1.0 POM model, separates build and consumer POMs to flatten dependencies, adds explicit classpath‑jar and module‑jar artifact types, renames modules to subprojects, and implements a tree‑based lifecycle for true parallel builds, all while remaining backward compatible.

Top Architect
Top Architect
Top Architect
What’s New in Maven 4? Model Upgrade, Flattened POMs, and Parallel Builds

Since Maven 3 was released in 2010, the Java build ecosystem has changed dramatically—modularization, parallel builds, cloud‑native containers, and rapid JDK releases—yet Maven itself remained largely unchanged. Maven 4, GA at the end of 2025, is the biggest architectural upgrade since Maven 2 and is designed as an evolution rather than a disruption.

POM Model Upgrade: 4.0.0 → 4.1.0

The POM model version is now 4.1.0. Maven 4 remains backward compatible, so projects using the old 4.0.0 model continue to build, but new capabilities only activate when the model version is 4.1.0. The modelVersion element can even be omitted because Maven can infer it from the schema.

<project xmlns="http://maven.apache.org/POM/4.1.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 http://maven.apache.org/xsd/maven-4.1.0.xsd">
  <modelVersion>4.1.0</modelVersion>
</project>

Build POM / Consumer POM Separation (Flattening)

Maven 3 publishes a single POM that mixes build configuration (plugins, parent references, unused properties) with the runtime dependencies required by consumers. Maven 4 introduces a flattened consumer POM that contains only the actual transitive dependencies, no plugin configuration, no parent POM, and all properties resolved to concrete values.

Backward compatible – Maven 4 can still build a 4.0.0 POM.

New capabilities apply only to the 4.1.0 model.

The modelVersion element can be omitted.

Enable flattening with:

mvn clean install -Dmaven.consumer.pom.flatten=true

In Maven 3 this required the external Flatten Maven Plugin ; in Maven 4 it is a native feature.

New Artifact Types: Explicit Classpath / Module‑Path Control

Previously, a plain JAR was placed on the classpath, and a JAR containing module-info.class was automatically treated as a module. Maven 4 adds explicit types:

<type>classpath-jar</type>
<type>module-jar</type>

This lets developers declare exactly where a dependency should appear. Example with Lombok:

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>${lombok.version}</version>
  <type>classpath-processor</type>
</dependency>
<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>${lombok.version}</version>
  <scope>provided</scope>
</dependency>

Maven 4 now distinguishes API classpath from processor classpath, making build semantics clearer and enabling better tool‑chain optimizations.

Modules Renamed to Subprojects

Java 9 introduced the module system, which left many developers confused about Maven’s <modules> element. Maven 4 deprecates <modules> and replaces it with <subprojects>:

<subprojects>
  <subproject>project-a</subproject>
  <subproject>project-b</subproject>
</subprojects>

Additional improvements:

Parent inference via an empty <parent/> element.

Automatic discovery of subprojects without explicit declaration.

Unified build timestamp and safe release – if any subproject fails, the whole release is aborted.

Tree‑Based Lifecycle for Parallel Builds

Maven 3’s lifecycle is linear, making parallel execution of multi‑module builds inefficient. Maven 4 introduces a tree‑based lifecycle where each subproject progresses independently as soon as its dependencies are ready, dramatically speeding up large builds.

mvn -b concurrent verify

Configuration Enhancements (Small Changes with Big Impact)

1. Conditional Profile Expressions

Profiles can now use full expression language instead of simple OS or JDK checks:

<condition>
  exists('${project.basedir}/src/**/*.xsd') && length(${user.name}) > 5
</condition>

2. Unified sources Model

Maven 3 required separate <sourceDirectory> and <testSourceDirectory>. Maven 4 consolidates them under a <sources> element, allowing multiple source directories, scopes, and custom locations.

<sources>
  <source>
    <scope>main</scope>
    <directory>my-custom-dir/foo</directory>
  </source>
  <source>
    <scope>test</scope>
    <directory>my-custom-dir/bar</directory>
  </source>
</sources>

Official Upgrade Tool

Maven 4 ships with mvnup to help migrate projects:

mvnup check   # generate a migration report
mvnup apply   # apply suggested changes automatically

The tool analyses POM files, plugins, and project structure, then produces executable upgrade suggestions.

Overall, Maven 4 delivers a dual upgrade: a semantic overhaul (new model, artifact types, subprojects) and practical engineering improvements (flattened consumer POMs, tree‑based lifecycle, richer configuration), positioning it as a modern build system for today’s modular, parallel, and cloud‑native Java applications.

JavamavenBuildParallelPOMArtifact
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.