Maven 4 Arrives After 15 Years: A Complete Rewrite of the Java Build Tool

Maven 4 introduces a split Build/Consumer POM model, a rewritten parallel engine that speeds up large builds by 50‑60%, incremental build with smart caching, automatic multi‑module discovery, native BOM and JPMS support, dynamic versioning, new packaging types, enhanced security, and a migration tool, all while remaining 100% compatible with Maven 3 plugins.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
Maven 4 Arrives After 15 Years: A Complete Rewrite of the Java Build Tool

Maven 3 has been unchanged since its 2010 release, accumulating a large amount of historical debt. Maven 4 is a bottom‑up rewrite that focuses on four directions: splitting the POM model, rewriting performance, adapting to modern Java, and upgrading developer experience. It remains fully compatible with the Maven 3 ecosystem while delivering higher capability, speed, and reliability.

Core architecture change – Build POM vs Consumer POM

In Maven 3 a single POM mixed build configuration and dependency metadata, leading to pollution, redundancy, and transitive‑dependency confusion. Maven 4 separates these concerns into two models:

Build POM (modelVersion 4.1.0) – used for local development and CI builds. It contains full configuration: plugins, profiles, build logic, directories.

Consumer POM (modelVersion 4.0.0) – used when publishing to a repository. It contains only minimal metadata (GAV, dependencyManagement, transitive dependencies).

Example of the model version change:

<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>my-app</artifactId>
<version>1.0.0</version>
<!-- Build config + dependency metadata mixed together -->
<build>...</build>
<dependencies>...</dependencies>

After migration to Maven 4 (Build POM 4.1.0):

<modelVersion>4.1.0<!-- new version --></modelVersion>
<groupId>com.demo</groupId>
<artifactId>my-app</artifactId>
<version>${revision}<!-- dynamic version --></version>
<!-- Full build config, visible only locally -->
<build>...</build>
<dependencies>...</dependencies>

Performance revolution

The parallel build engine has been completely rewritten. Benchmarks on a large project show substantial gains:

4‑thread build: 5m48s (Maven 3) → 3m22s (Maven 4) – 42 % faster

8‑thread build: 4m55s (Maven 3) → 2m38s (Maven 4) – 46 % faster

Cache hit rate: 62 % → 85 % – +23 %

Dependency I/O reads/writes: 15k/8.9k → 8.5k/5.4k – -44 % / -39 %

Additional improvements include incremental build & resume (failed builds can continue without a full rebuild), a smart cache based on file fingerprints and dependency‑tree verification, and a >30 % speedup in dependency resolution.

POM syntax & multi‑module

Automatic sub‑project discovery – no need to declare <modules> manually.

Atomic deployment – a failing sub‑module does not block others.

Version inheritance – parent version can be omitted and is automatically inherited.

Example of automatic module discovery (Maven 3 required explicit declaration):

<modules>
  <module>user-service</module>
  <module>order-service</module>
  <module>pay-service</module>
</modules>

Native BOM packaging type

<packaging>bom<!-- native type --></packaging>
<dependencyManagement>
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>3.2.0</version>
    <scope>import</scope>
  </dependency>
</dependencyManagement>

Unified sources model

<sources>
  <source>
    <scope>main</scope>
    <directory>src/main/java</directory>
  </source>
  <source>
    <scope>main</scope>
    <directory>src/generated/java</directory>
  </source>
  <source>
    <scope>test</scope>
    <directory>src/test/java</directory>
  </source>
</sources>

Dynamic versioning (native ${revision})

<properties>
  <revision>2.1.0</revision>
</properties>
<version>${revision}</version>

JPMS (Java Platform Module System) support

Baseline JDK 17+ (projects can still compile for JDK 8/11).

Two new packaging types without plugins: classpath-jar – traditional non‑modular JAR. modular-jar – explicit module JAR containing module-info.java.

<packaging>modular-jar</packaging>
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.13.0</version>
      <configuration>
        <release>17</release>
        <modular>true</modular>
      </configuration>
    </plugin>
  </plugins>
</build>

Security & credential management

New password encryption supporting command‑line and external vault integration.

Dependency checksum verification (SHA‑256) to prevent tampering.

Settings 5.0 introduces a new XML schema.

Migration tool & compatibility

The official mvnup tool checks compatibility, lists deprecated APIs, and can automatically upgrade POMs to version 4.1.0:

mvnup check   # check compatibility, list deprecated APIs
mvnup apply   # automatically upgrade POM to 4.1.0

99 % of Maven 3 plugins work without modification.

Maven 4 itself requires JDK 17+, while project code can continue to target JDK 8/11.

Core feature comparison (Maven 3 vs Maven 4)

Runtime JDK : Maven 3 – JDK 7+; Maven 4 – JDK 17+.

POM model : Maven 3 – single 4.0.0 model; Maven 4 – Build (4.1.0) + Consumer (4.0.0).

Multi‑module : Maven 3 – manual <modules>; Maven 4 – automatic sub‑project discovery.

Parallel build : Maven 3 – unstable, noisy logs; Maven 4 – rewritten engine, 50 %+ speedup.

BOM support : Maven 3 – pom packaging + plugin; Maven 4 – native bom packaging.

Dynamic version : Maven 3 – requires flatten plugin; Maven 4 – native ${revision}.

JPMS : Maven 3 – plugin adaptation; Maven 4 – native modular-jar.

Incremental build : Maven 3 – basic support; Maven 4 – resume, smart cache.

Consumer POM : Maven 3 – none (full publish); Maven 4 – automatic slimming, no redundancy.

Source directories : Maven 3 – single directory; Maven 4 – multiple directories via unified sources.

Lifecycle : Maven 3 – fixed; Maven 4 – new hooks before:all / each.

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.

Incremental BuildperformancemavenJPMSJava Build ToolMaven4
Code Ape Tech Column
Written by

Code Ape Tech Column

Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn

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.