SSerguey Asael Shinder
Java coding notes: the JVM, and writing software that lasts

Serguey Asael Shinder: Maven 3.10.1 drops JLine for plain ANSI colours and fixes how it finds the project root

· by Serguey Asael Shinder / Serguey Shinder

Apache Maven 3.10.1 was published on GitHub on 15 November. The release notes describe it as a bugfix release for 3.10.0: it fixes regressions reported after 3.10.0, backports fixes from Maven 4 and makes startup lighter. It still runs on Java 8 or later, like the 3.9.x line.

The visible change is in the terminal. Maven no longer ships the JLine terminal stack, which the notes describe as native libraries, a background setup thread and a replacement for System.out and System.err. Coloured output is now plain ANSI escape codes, maven.style.* overrides still apply, and the startup overhead added in 3.10.0 is gone. A shim keeps JAnsi compatibility. One known issue follows from it: in Windows cmd.exe there is no colour by default, and --color=always turns it back on, on the command line, in .mvn/maven.config or in MAVEN_ARGS.

Two small features come from Maven 4. Optional profiles can be requested with -P ?id, the same syntax as Maven 4, so one command line works for both (#13480). And plugins built against maven-api-core 4.x can inject org.apache.maven.api.services.MessageBuilderFactory on 3.10 and get coloured output as they would on Maven 4.

Two of the fixes are worth reading in full.

Serguey Asael Shinder: Maven 3.10.1 drops JLine for plain ANSI colours and fixes how it finds the project root
Maven 3.10.1 drops JLine for plain ANSI colours and fixes how it finds the project root — Serguey Asael Shinder

Loopback is more than 127.0.0.1. A mirror defined with mirrorOf external:* applies to every repository that is not local. An issue opened in 2021 (#8320, originally MNG-7132) reported that Maven detected only a couple of special cases, such as 127.0.0.1, as local, missing IPv6 loopback and the rest of 127.x.y.z. The backport in #13526 replaces isLocal() in both DefaultMirrorSelector and MavenRepositorySystem with detection of the whole IPv4 127.0.0.0/8 range and of bracketed IPv6 addresses, with tests for loopback and external hosts.

The project root is resolved as text, not by the OS. Issue #11167 came from a user who worked on a Windows drive H: mapped to a network share. With JDK 21 the build worked; with JDK 25 and nothing else changed, Maven failed with "Non-readable POM" on a path that glued the network location onto the drive letter, H:\colo-01-fs02\.... The fix in #13650 explains why: MavenCli#initialize resolved multiModuleProjectDirectory with File#getCanonicalFile(), which asks the operating system and can follow a symlink, a junction or, on Windows since JDK-8355342, a mapped network drive to a different location. Every module and parent path resolved against that corrupted root broke. The directory is now normalised lexically, through a helper the class already used elsewhere, and a new test reproduces the same kind of divergence on Linux with a symlink.

The full changelog lists more: a thread-safe DefaultModelValidator, quotes in MAVEN_ARGS honoured by bin/mvn, the password to encrypt read from standard input when there is no console, and Resolver 2.0.25 and Surefire and Failsafe 3.6.1 as dependencies.

The mapped-drive fix is the one I would point a Windows team to. A build that breaks when only the JDK is changed looks like a JDK bug, and here it was Maven asking the platform a question whose answer had changed.