Maven 4 Arrives: A Complete Overhaul of Java Build Tools After 15 Years

Maven 4, now in its fifth release candidate, introduces a new POM model, consumer‑POM flattening, explicit artifact types, subproject renaming, a tree‑based lifecycle and richer configuration, all aimed at modernizing Java builds for modular, parallel, and cloud‑native environments.

SpringMeng
SpringMeng
SpringMeng
Maven 4 Arrives: A Complete Overhaul of Java Build Tools After 15 Years

Since Maven 3 was released in 2010, the Java ecosystem has undergone major changes—module systems, parallel builds, cloud‑native containerization, and rapid JDK releases—while Maven itself has remained largely unchanged.

Maven 4 is designed to address these accumulated shortcomings. Although a final GA date is not announced, the project has reached its fifth release candidate (RC5), indicating it is close to a stable release.

POM Model Upgrade

The POM model version is upgraded to 4.1.0 . Maven 4 remains backward compatible, so it can still build projects using the 4.0.0 POM, while new capabilities only apply to the 4.1.0 model. The modelVersion element can even be omitted because Maven can infer it from the schema.

Build POM / Consumer POM Separation (Flattening)

In Maven 3, a published POM contains plugin configuration, build details, parent references, and various properties, forcing downstream consumers to parse a lot of irrelevant information. Maven 4 solves this with POM flattening, producing a consumer POM that:

excludes plugin configuration

excludes the parent POM

excludes unused dependencies

keeps only real transitive dependencies

resolves properties to concrete values

Flattening is enabled via the command line:

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

Unlike Maven 3, which required the external flatten-maven-plugin, Maven 4 provides this as a native capability, making dependency resolution cleaner and more predictable.

New Artifact Types for Explicit Classpath/Module‑Path Control

Maven 3 implicitly placed ordinary JARs on the classpath and JARs containing module-info.class on the module path. Maven 4 introduces explicit types:

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

This lets developers declare exactly where a dependency belongs. For example, Lombok’s annotation processor can be declared as:

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

Maven 4 also distinguishes API classpath from processor classpath, clarifying build semantics.

Modules Renamed to Subprojects

To better align with Java 9 modules, Maven 4 deprecates the modules element and introduces subprojects:

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

Additional improvements include automatic parent inference ( <parent/>), automatic subproject discovery, unified build timestamps, and safe release semantics where a failure in any subproject aborts the whole release.

Tree‑Based Lifecycle

Maven 3’s lifecycle is linear, making parallel execution of large multi‑module builds inefficient. Maven 4 introduces a Tree‑based Lifecycle where each subproject advances independently, starting as soon as its dependencies are ready. This dramatically speeds up large builds. Enable it with:

mvn -b concurrent verify

Enhanced Configuration Capabilities

Conditional profiles now support full expression syntax instead of simple OS or JDK checks, e.g.:

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

The source configuration is unified under a sources element, allowing multiple directories, scopes, and versions:

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

This model is especially suitable for projects with multiple source directories, multiple Java versions, or those that avoid plugin configuration.

Official Upgrade Tool

Maven 4 ships with mvnup to help migrate existing projects:

mvnup check   # generate a migration report
mvnup apply   # apply automatic changes

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

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

javaBuild Tooldependency managementmavenParallel BuildPOMMaven4
SpringMeng
Written by

SpringMeng

Focused on software development, sharing source code and tutorials for various systems.

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.