You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-commits@maven.apache.org by sv...@apache.org on 2025/02/26 16:32:01 UTC
svn commit: r1924057 [7/7] - in /maven/website/content: ./ archives/maven-2.x/ background/ developers/ developers/conventions/ developers/release/ developers/website/ docs/ docs/2.0.1/ docs/2.0.10/ docs/2.0.11/ docs/2.0.2/ docs/2.0.3/ docs/2.0.4/ docs/...
Added: maven/website/content/whatsnewinmaven4.html
==============================================================================
--- maven/website/content/whatsnewinmaven4.html (added)
+++ maven/website/content/whatsnewinmaven4.html Wed Feb 26 16:31:58 2025
@@ -0,0 +1,542 @@
+<!DOCTYPE html>
+
+
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 2.0.0 from content/markdown/whatsnewinmaven4.md at 2025-02-26
+ | Rendered using Apache Maven Fluido Skin 2.0.1
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" />
+ <meta name="author" content="Matthias Bünger" />
+ <title>What's new in Maven 4? â Maven</title>
+ <link rel="stylesheet" href="./css/apache-maven-fluido-2.0.1.min.css" />
+ <link rel="stylesheet" href="./css/site.css" />
+ <link rel="stylesheet" href="./css/print.css" media="print" />
+ <script src="./js/apache-maven-fluido-2.0.1.min.js"></script>
+ <!-- Matomo -->
+ <script>
+ var _paq = window._paq = window._paq || [];
+ _paq.push(['disableCookies']);
+ _paq.push(['trackPageView']);
+ _paq.push(['enableLinkTracking']);
+
+ (function() {
+ var u="https://analytics.apache.org/";
+ _paq.push(['setTrackerUrl', u+'/matomo.php']);
+ _paq.push(['setSiteId', '3']);
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+ g.async=true; g.src=u+'/matomo.js'; s.parentNode.insertBefore(g,s);
+ })();
+ </script>
+ <!-- End Matomo Code -->
+ </head>
+ <body>
+ <div class="container-fluid container-fluid-top">
+ <header>
+ <div id="banner">
+ <div class="pull-left"><div id="bannerLeft"><h1><a href="https://www.apache.org/"><img class="class java.lang.Object" src="images/apache-maven-project.png" /></a></h1></div></div>
+ <div class="pull-right"><div id="bannerRight"><h1><a href="./"><img class="class java.lang.Object" src="images/maven-logo-black-on-white.png" /></a></h1></div></div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="breadcrumbs">
+ <ul class="breadcrumb">
+ <li><a href="https://www.apache.org/" class="externalLink">Apache</a><span class="divider">/</span></li>
+ <li><a href="index.html">Maven</a><span class="divider">/</span></li>
+ <li class="active">What's new in Maven 4? <a href="https://github.com/apache/maven-site/tree/master/content/markdown/whatsnewinmaven4.md"><img src="./images/accessories-text-editor.png" alt="Edit" /></a></li>
+ <li id="publishDate" class="pull-right"><span class="divider">|</span> Last Published: 2025-02-26</li>
+ <li class="pull-right"><span class="divider">|</span>
+<a href="scm.html">Get Sources</a></li>
+ <li class="pull-right"><a href="download.cgi">Download</a></li>
+ </ul>
+ </div>
+ </header>
+ <div class="row-fluid">
+ <header id="leftColumn" class="span2">
+ <nav class="well sidebar-nav">
+ <ul class="nav nav-list">
+ <li><a href="index.html">Welcome</a></li>
+ <li><a href="https://www.apache.org/licenses/" class="externalLink">License</a></li>
+ <li class="nav-header">About Maven</li>
+ <li><a href="what-is-maven.html">What is Maven?</a></li>
+ <li><a href="maven-features.html">Features</a></li>
+ <li><a href="download.html">Download</a></li>
+ <li><a href="users/index.html"><span class="icon-chevron-right"></span>Use</a></li>
+ <li><a href="docs/history.html">Release Notes</a></li>
+ <li class="active"><a>What's new in Maven 4?</a></li>
+ <li class="nav-header">Documentation</li>
+ <li><a href="plugins/index.html">Maven Plugins</a></li>
+ <li><a href="extensions/index.html">Maven Extensions</a></li>
+ <li><a href="tools/index.html">Maven Tools</a></li>
+ <li><a href="guides/index.html">Index (category)</a></li>
+ <li><a href="users/index.html"><span class="icon-chevron-right"></span>User Centre</a></li>
+ <li><a href="plugin-developers/index.html"><span class="icon-chevron-right"></span>Plugin Developer Centre</a></li>
+ <li><a href="repositories/index.html"><span class="icon-chevron-right"></span>Maven Repository Centre</a></li>
+ <li><a href="developers/index.html"><span class="icon-chevron-right"></span>Maven Developer Centre</a></li>
+ <li><a href="articles.html">Books and Resources</a></li>
+ <li><a href="security.html">Security</a></li>
+ <li class="nav-header">Community</li>
+ <li><a href="community.html">Community Overview</a></li>
+ <li><a href="project-roles.html">Project Roles</a></li>
+ <li><a href="guides/development/guide-helping.html">How to Contribute</a></li>
+ <li><a href="users/getting-help.html">Getting Help</a></li>
+ <li><a href="issue-management.html">Issue Management</a></li>
+ <li><a href="scm.html">Getting Maven Source</a></li>
+ <li><a href="team.html">The Maven Team</a></li>
+ <li class="nav-header">Project Documentation</li>
+ <li><a href="project-info.html"><span class="icon-chevron-right"></span>Project Information</a></li>
+ <li class="nav-header">Maven Projects</li>
+ <li><a href="ref/current">Maven</a></li>
+ <li><a href="archetypes/index.html">Archetypes</a></li>
+ <li><a href="extensions/index.html">Extensions</a></li>
+ <li><a href="pom/index.html">Parent POMs</a></li>
+ <li><a href="plugins/index.html">Plugins</a></li>
+ <li><a href="skins/index.html">Skins</a></li>
+ <li><a><span class="icon-chevron-down"></span>Components</a>
+ <ul class="nav nav-list">
+ <li><a href="archetype/index.html">Archetype</a></li>
+ <li><a href="resolver/index.html">Artifact Resolver</a></li>
+ <li><a href="doxia/index.html">Doxia</a></li>
+ <li><a href="maven-indexer/index.html">Indexer</a></li>
+ <li><a href="jxr/index.html">JXR</a></li>
+ <li><a href="plugin-testing/index.html">Plugin Testing</a></li>
+ <li><a href="plugin-tools/index.html">Plugin Tools</a></li>
+ <li><a href="apache-resource-bundles/index.html">Resource Bundles</a></li>
+ <li><a href="scm/index.html">SCM</a></li>
+ <li><a href="shared/index.html">Shared Components</a></li>
+ <li><a href="surefire/index.html">Surefire</a></li>
+ <li><a href="wagon/index.html">Wagon</a></li>
+ </ul></li>
+ <li class="nav-header">ASF</li>
+ <li><a href="https://www.apache.org/foundation/how-it-works.html" class="externalLink">How Apache Works</a></li>
+ <li><a href="https://www.apache.org/foundation/" class="externalLink">Foundation</a></li>
+ <li><a href="https://privacy.apache.org/policies/privacy-policy-public.html" class="externalLink">Data Privacy</a></li>
+ <li><a href="https://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsoring Apache</a></li>
+ <li><a href="https://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a></li>
+ </ul>
+ </nav>
+ <div class="well sidebar-nav">
+ <div id="poweredBy">
+ <div class="clear"></div>
+ <div class="clear"></div>
+<a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
+ </div>
+ </div>
+ </header>
+ <main id="bodyColumn" class="span10">
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<section><a id="What.27s_new_in_Maven_4.3F"></a>
+<h1>What's new in Maven 4?</h1>
+<p><strong>Note</strong>: This article will continuously be updated at least until Maven 4.0.0 is released.</p>
+<p>Maven is over 20 years old, and is the most widely used build tool in the Java world.
+Throughout the years, Maven has maintained backward compatibility, especially of its <a href="https://maven.apache.org/pom.html" class="externalLink">POM file</a> with Model version
+4.0.0.</p>
+<p>The POM file fulfills two needs.
+First, the POM holds all the information and configuration, which are needed to build the artifact.
+After the artifact is created, this build information is not relevant anymore.
+Second, the POM also contains information, for example dependencies, which are needed by projects which depend on the
+artifact.
+These dependent projects are called the “consumers”.</p>
+<p>This made Maven more than a tool; it became a whole ecosystem with many dependencies on the POM, especially the
+Maven Central repository, other build tools, and IDEs.
+Thus, any change in the POM's schema forces each participant of the ecosystem to either adopt the change or drop
+support.
+Thus, the Maven POM syntax became fixed, unable to change.</p>
+<blockquote>
+
+<p>"With the Maven build schema preserved in amber, we can’t evolve much: we’ll stay forever with Maven 3 minor releases,</p>
+<blockquote>
+
+<p>unable to implement improvements that we imagine will require seriously updating the POM schema…"
+— <cite><a href="https://www.javaadvent.com/2021/12/from-maven-3-to-maven-5.html" class="externalLink">Hervé Boutemy (in Javaadvent 2021)</a></cite></p>
+</blockquote>
+</blockquote>
+<p>In order for Maven to evolve, it's necessary to separate the information needed for the build from the information
+needed by the consumers, but without breaking the ecosystem.
+Maven 4 prepares for this and more.</p>
+<p>This article presents and explains major changes brought by Maven 4, grouped into several topics.</p><section><a id="Required_Java_version"></a>
+<h2>Required Java version</h2>
+<p>Maven 4 requires Java 17.
+This allows Maven (and its maintainers) to make use of newer language features and improvements.</p>
+<p><strong>Important note</strong>: Java 17 is only needed to <strong>run Maven</strong>!
+You can still compile against older Java versions using the same <a href="https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html" class="externalLink">compiler plugin configuration</a> as before.
+If you need to compile against or use another JDK, see the <a href="https://maven.apache.org/guides/mini/guide-using-toolchains.html" class="externalLink">Guide to Using Toolchains</a> (or the
+article <a href="https://maarten.mulders.it/2021/03/introduction-to-maven-toolchains/" class="externalLink">Introduction to Maven Toolchains</a> by Maven maintainer Maarten Mulders).</p></section><section><a id="POM_Changes"></a>
+<h2>POM Changes</h2><section><a id="Consumer_POM"></a>
+<h3>Consumer POM</h3>
+<p>Maven 4 generates a stripped down consumer POM that removes build information not needed by consumers, and deploys this
+to the remote repository.
+It does not deploy the <code>pom.xml</code> used to build the project.</p></section><section><a id="Model_version_4.1.0"></a>
+<h3>Model version 4.1.0</h3>
+<p>Maven 4 updates the POM version to 4.1.0 which defines the namespace <code>http://maven.apache.org/POM/4.1.0</code>.
+Version 4.1.0 adds some new elements and attributes, while others are marked as deprecated.
+To not break the ecosystem, this version is only available for the build POM, while the consumer POM will still use
+version 4.0.0.
+Maven generates the consumer POM during the build from the build POM.</p>
+<p><strong>Note</strong>: Maven 4 will continue to build your model version 4.0.0 project.
+There is no need to update your POMs to 4.1.0 if you don't need to use the new features.</p></section><section><a id="Modules_are_now_subprojects"></a>
+<h3>Modules are now subprojects</h3>
+<p>A Maven project is any Java project built with Maven.
+The <a href="https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html" class="externalLink">top level directory</a> of a Maven project contains at least the source folder <code>src</code> and the project's POM file
+<code>pom.xml</code>.
+A Maven project may have other Maven projects within subdirectories, each with its own <code>pom.xml</code> file.
+Each project within a subdirectory is called a “subproject”.</p>
+<p>Example: Project A contains a subdirectory which contains its own POM file for project B.
+We say that B is a subproject of A.</p>
+<p>However, Maven does not build subprojects unless they are linked from the root POM file.
+In the past this was done by listing each subproject in the <code><modules></code> section of the parent's POM.
+Projects which have at least one subproject are called “multi-module projects”, while those which do not have any
+subprojects are called “single module projects”.
+Since the introduction of the <a href="https://en.wikipedia.org/wiki/Java_Platform_Module_System" class="externalLink">Java Platform Module System</a> in Java 9, the term “module” has raised additional
+confusion inside the Maven community.</p>
+<p>Maven 4 gets rid of this by renaming modules to projects and submodules to subprojects.
+Model version 4.1.0 contains a new <code><subprojects></code> element analogous to the now deprecated, but still usable,
+<code><modules></code> element.</p>
+<p><strong>Note</strong>: Use the terms <code>multi-project setup</code> and <code>single-project setup</code> to differentiate between a Maven project with
+or without subprojects.</p></section><section><a id="New_packaging_type.3A_bom"></a>
+<h3>New packaging type: bom</h3>
+<p>Maven 4 introduces a dedicated <code>bom</code> packaging type to provide a <a href="https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms" class="externalLink">Bill of Materials BOM</a>.
+This now differentiates between parent POMs and dependency-managing BOMs.
+The new type is only available as a build POM in Model Version 4.1.0 and later, but Maven generates a full Maven 3
+compatible consumer POM during the build.
+For an example, see the link above or
+the <a href="https://www.youtube.com/watch?v=ZD_YxTmQ16Q&t=16710s" class="externalLink">live coding by Maven maintainer Karl Heinz Marbaise at IntelliJ IDEA Conf 2024</a>.</p>
+<p><strong>Note</strong>: With Maven 4, it's also possible to exclude dependencies that are declared by BOMs using the existing
+<code><exclusions></code> element.
+Also note that in Maven 4, importing BOMs with a classifier is now possible.
+Therefore, the Maven team suggests that project BOMs should be generated as classified artifacts, using the
+<code><bomClassifier></code> element.
+This means that an imported BOM must <strong>not</strong> come from the same reactor as the current build but be available outside
+the project before the build.
+In other words: you should only import external BOMs.
+That's why Maven 4.0 will show a warning if a BOM comes from the same reactor.
+In the future, this will most probably be changed to make the build fail.</p></section><section><a id="Comparing_build_POM_and_consumer_POM"></a>
+<h3>Comparing build POM and consumer POM</h3>
+<p>The following table shows a rough comparison of which content is available in which POM type when using Maven 4.</p>
+<p><strong>Notes</strong>:</p>
+<ul>
+
+<li>The column “consumer POM” does not apply to artifacts that are of type “pom”, because “pom”-artifacts are designed to
+contain build information, for example plugin configuration!</li>
+<li>Some of the build-related content which is (as of now) still available in the consumer POM might be available only in
+the build POM in the future.</li>
+</ul>
+<table class="table table-striped">
+<thead>
+<tr class="a">
+<th>Content</th>
+<th>Build POM</th>
+<th>Consumer POM</th></tr></thead><tbody>
+<tr class="b">
+<td>Model version</td>
+<td>4.1.0</td>
+<td>4.0.0</td></tr>
+<tr class="a">
+<td>3rd party dependency information</td>
+<td>✅</td>
+<td>✅</td></tr>
+<tr class="b">
+<td>POM properties</td>
+<td>✅</td>
+<td>❌</td></tr>
+<tr class="a">
+<td>Plugin configuration</td>
+<td>✅</td>
+<td>❌</td></tr>
+<tr class="b">
+<td>Repository information</td>
+<td>✅</td>
+<td>✅</td></tr>
+<tr class="a">
+<td>Project information / environment settings</td>
+<td>✅</td>
+<td>✅</td></tr>
+<tr class="b">
+<td>Deployment to remote repository</td>
+<td>✅</td>
+<td>✅</td></tr></tbody>
+</table>
+
+<p><strong>Warning</strong>: There are rare situations where Maven 4 will produce a consumer POM based on version 4.1.0, for example
+when
+condition-based profiles (see below) can't be transformed to version 4.0.0.
+Maven will show a warning in such situations.</p></section><section><a id="Declaring_the_root_directory_and_directory_properties"></a>
+<h3>Declaring the root directory and directory properties</h3>
+<p>Every time Maven executes a build, it has to determine the project's root to identify things like the parent project,
+directory information, and so on.
+To “help” Maven find the root folder, you can create a <code>.mvn</code> folder in your root directory.
+This folder is intended to contain project-specific configuration to run Maven, for example a <code>maven.config</code> or
+<code>jvm.config</code>
+file, and therefore was also considered as the root folder.
+With Maven 4, there is a second option to clearly define the root folder.
+Model version 4.1.0, usable for the build POM, adds a boolean attribute called <code>root</code> in the <code><project></code> element.
+When this attribute is set to true (default is false), the directory of this POM file is considered the root directory.</p>
+<p>Another pain point in relation to the root directory is that until Maven 4, there was no official property to make use
+of the root folder in your POM files, for example when you want to define the path to a <code>checkstyle-suppressions.xml</code>
+file for the checkstyle plugin.
+Maven 4 now provides official properties to reference the root directory in your POM configuration.
+The following table shows the official properties.</p>
+<table class="table table-striped">
+<thead>
+<tr class="a">
+<th>Property</th>
+<th>Scope</th>
+<th>Definition</th>
+<th>Always</th></tr></thead><tbody>
+<tr class="b">
+<td><code>${project.rootDirectory}</code></td>
+<td>Project</td>
+<td><code>.mvn</code> folder or <code>root</code> attribute in pom</td>
+<td>No</td></tr>
+<tr class="a">
+<td><code>${session.topDirectory}</code></td>
+<td>Session</td>
+<td>Current directory or <code>--file</code> argument</td>
+<td>Yes</td></tr>
+<tr class="b">
+<td><code>${session.rootDirectory}</code></td>
+<td>Session</td>
+<td><code>.mvn</code> folder or <code>root</code> attribute in pom for the <code>topDirectory</code> project</td>
+<td>No</td></tr></tbody>
+</table>
+
+<p>As you can see, these properties differentiate by their scope, where <code>project</code> is always related to the Maven project's
+definition (you could interpret this as the POM files) and <code>session</code> is the actual execution of a Maven build and is the
+current working directory.
+The <code>rootDirectory</code> can only contain a value when either a <code>.mvn</code> directory is defined or the <code>root</code> attribute is set to
+true.
+However, if defined, it should always have the same value for a given project, whereas the value of the <code>topDirectory</code>
+property can change depending on the execution point.</p>
+<p>Keep in mind that the root directory of the whole project (when considering multiple subprojects) is different from each
+subproject's own base directory, which is accessible via the <code>${basedir}</code> property for use in POM
+files and will always have a value.</p>
+<p><strong>Note:</strong> In the past, some people “hacked” workarounds for the <code>rootDirectory</code> properties, mostly by using internal
+properties.
+Starting with Maven 4 those properties were removed or marked as deprecated.
+See JIRA issue <a href="https://issues.apache.org/jira/browse/MNG-7038" class="externalLink">MNG-7038</a> and the related <a href="https://github.com/apache/maven/pull/1061" class="externalLink">Pull Request for MNG-7038</a> for more information.</p></section><section><a id="Alternate_POM_syntaxes"></a>
+<h3>Alternate POM syntaxes</h3>
+<p>While the syntax for the 4.0.0 consumer POM is set in stone, the build POM should be able to evolve.
+This includes allowing the use of alternate syntaxes by having Maven 4 provide a ModelParser SPI (<a href="https://issues.apache.org/jira/browse/MNG-7836" class="externalLink">MNG-7836</a>),
+which can be implemented as a core extension and allow a custom syntax.</p>
+<p>One of the first projects that uses this feature is the <a href="https://github.com/apache/maven-hocon-extension" class="externalLink">Apache Maven Hocon Extension</a>.</p></section></section><section><a id="Improvements_for_subprojects"></a>
+<h2>Improvements for subprojects</h2><section><a id="Automatic_versioning"></a>
+<h3>Automatic versioning</h3>
+<p>Maven 4 finally ships one of the oldest improvement requests - automatic parent versioning (<a href="https://issues.apache.org/jira/browse/MNG-624" class="externalLink">MNG-624</a>, created in
+July 2005 and originally planned for Maven 2)!
+As expected, it's no longer required to define the parent versions in each subproject when using the new model version
+4.1.0.
+This also extends to dependencies of project's own subprojects and reduces the need to update POM files for new
+versions even more.</p>
+<p>The following code snippet shows the parent and dependency definition without the version tag.</p>
+
+<pre class="prettyprint linenums"><code class="language-xml">
+<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>
+
+ <parent>
+ <groupId>my.parents.groupId</groupId>
+ <artifactId>my.parents.artifactId</artifactId>
+ </parent>
+
+ <artifactId>myOwnSubprojectArtifactId</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>the.dependent.subproject.groupId</groupId>
+ <artifactId>the.dependent.subproject.artifactId</artifactId>
+ </dependency>
+ </dependencies>
+</project>
+</code></pre></section><section><a id="Full_support_of_CI-friendly_variables"></a>
+<h3>Full support of CI-friendly variables</h3>
+<p>Maven 3.5.0 introduced partial support for CI-friendly variables, like <code>${revision}</code>, in your POM files.
+However, this still required the usage of the <a href="https://www.mojohaus.org/flatten-maven-plugin/" class="externalLink">Flatten Maven Plugin</a> for full functionality.
+Since Maven 4, no additional plugin is needed; full built-in support is provided.
+You can now use variables as versions in your configuration.</p>
+<p>Example</p>
+
+<pre class="prettyprint linenums"><code class="language-xml">
+<groupId>my.groupId</groupId>
+<artifactId>my.artifactId</artifactId>
+<version>${revision}</version>
+</code></pre>
+<p>You have to provide a value for this variable when starting the build, for example by using a <code>maven.config</code> file.
+In CI pipelines it's commonly done using a parameter, for example <code>mvn verify -Drevision=4.0.1</code>.</p>
+<p>Maven maintainer Karl Heinz Marbaise shows a larger example in
+his <a href="https://blog.soebes.io/posts/2024/03/2024-03-31-maven-4-part-i/" class="externalLink">article “Maven 4 - Part I - Easier Versions” (2024)</a>.</p></section><section><a id="Reactor_improvements_and_fixes"></a>
+<h3>Reactor improvements and fixes</h3>
+<p>Building a project with multiple subprojects can cause confusion in Maven 3.
+When the build of subproject B, which requires subproject A, is failing for whatever reason, Maven 3 is telling
+the user to fix the error and then resume the build with <code>--resume-from :<nameOfTheFailingSubproject></code>.
+But doing this instantly fails the build again, because the required subproject A couldn't be found (as it was not
+rebuilt).
+Using <code>--also-make :<nameOfTheDependentSubproject></code> was no help in the past as it was ignored due to the long-standing
+bug <a href="https://issues.apache.org/jira/browse/MNG-6863" class="externalLink">MNG-6863</a> - which is finally fixed with Maven 4!</p>
+<p><strong>Recommendation: Do not use <code>mvn clean install</code>.
+Instead, use <code>mvn verify</code> for your regular builds!</strong></p>
+<p>To improve usability when resuming a failed build, you can now use <code>--resume</code> or its short parameter <code>-r</code> to resume a
+build from the subproject that last failed.
+So you don't have to manually pass the name of the failed subproject as the starting point to resume from.
+The reactor is now also aware of successfully built subprojects when the overall build failed and will skip rebuilding
+those if you resume the build.<br />
+With Maven 4, it's also aware of subfolder builds <a href="https://issues.apache.org/jira/browse/MNG-6118" class="externalLink">MNG-6118</a>, which becomes pretty handy when you only want to
+execute tools (for example Jetty) on/with certain subprojects, but not on every subproject.
+See Maven maintainer Maarten Mulders's article <a href="https://maarten.mulders.it/2020/11/whats-new-in-maven-4/" class="externalLink">“What's New in Maven 4” (2020)</a> for a small example.</p></section><section><a id="Further_improvements"></a>
+<h3>Further improvements</h3>
+<p>Further improvements to subprojects will also improve daily work with them.
+Thanks to <a href="https://issues.apache.org/jira/browse/MNG-6754" class="externalLink">MNG-6754</a>, all subprojects will now have consistent timestamps in their packaged archives, while in Maven
+3, each subproject had a different one.
+This should make it easier to identify the archives that belong together.
+When using Maven 3, deploying a project with multiple subprojects could end up in a situation where successfully
+built subprojects were deployed to the (local or remote) repository, but failed subprojects were not.
+This was finally changed in Maven 4 to what most users expect:
+Only deploy when all subprojects are built successfully.
+This means that the default value of the <code>deployAtEnd</code> parameter is now <code>true</code>.</p></section></section><section><a id="Workflow.2C_lifecycle_and_runtime_changes"></a>
+<h2>Workflow, lifecycle and runtime changes</h2><section><a id="Application_maintenance"></a>
+<h3>Application maintenance</h3>
+<p>As with every major update, extensive application maintenance has occurred, including significant code, API, and
+dependency updates.
+For example, the “Plexus Containers” dependency injection was removed - after being deprecated since Maven 3.2 (2010)!
+Code updates include not only newer Java language features but also changes to make maintenance easier and
+less time-consuming.
+This also includes removing features that either should never have worked or were only kept for backward compatibility
+in Maven 3, for example using <code>${pom.*}</code> expressions.
+Maven's own Super POM was also upgraded, which declares new default versions of Maven's core plugins.</p>
+<p><strong>Note</strong>: Due to upgrading the default versions of Maven plugins, your build might behave differently than before, even
+if you didn't purposely change anything.
+To avoid this situation, always define fixed versions of all the plugins you use.
+By doing this, you are in control of your build.
+Maven 4 will issue a warning if you rely on default versions defined in Maven's Super POM.</p></section><section><a id="a.E2.80.9CFail_on_severity.E2.80.9D_parameter"></a>
+<h3>“Fail on severity” parameter</h3>
+<p>Maven 4 introduces a “fail on severity” build parameter, which breaks the build when the severity of at least one log
+message matches the given argument.</p>
+<p>The parameter can either be used by its full name (<code>--fail-on-severity</code>) or as a short handle (<code>-fos</code>).
+The parameter is followed by an argument specifying a log level severity, for example, <code>WARN</code>.</p></section><section><a id="Improvements_to_profiles"></a>
+<h3>Improvements to profiles</h3>
+<p>Trying to use a nonexistent profile in a build causes the build to fail, as the following command line snippet shows:</p>
+
+<pre><code class="nohighlight nocode">> mvn compile -Pnonexistent
+[ERROR] The requested profiles [nonexistent] could not be activated or deactivated because they do not exist.
+</code></pre>
+<p>Maven 4 introduces the possibility to only use profiles when they exist.
+To do so, the <code>?</code> argument was added to the profile parameter.
+When using this, the build won't break.
+Instead, an information message will be printed twice (at the start and end).
+See the following snippet for an example:</p>
+
+<pre><code class="nohighlight nocode">> mvn compile -P?nonexistent
+[INFO] The requested optional profiles [nonexistent] could not be activated or deactivated because they do not exist.
+[...]
+[INFO] BUILD SUCCESS
+[INFO] ----------------------------------------------------------------------------------------------------------------
+[INFO] Total time: 0.746 s
+[INFO] Finished at: 2024-12-14T13:24:15+01:00
+[INFO] ----------------------------------------------------------------------------------------------------------------
+[INFO] The requested optional profiles [nonexistent] could not be activated or deactivated because they do not exist.
+</code></pre>
+<p>Maven 4 also introduces more flexible ways to activate profiles by providing condition-based activation.
+See <a href="https://issues.apache.org/jira/browse/MNG-8286" class="externalLink">MNG-8286</a> for more information about supported functions.</p></section><section><a id="Lifecycle_changes"></a>
+<h3>Lifecycle changes</h3><section><a id="Lifecycle_changed_from_graph_to_tree"></a>
+<h4>Lifecycle changed from graph to tree</h4>
+<p>In Maven 3 the lifecycle is an ordered list containing all phases.
+This changed with Maven 4, where the lifecycle is defined as a tree of phases.
+This allows for more fine-grained execution of dependent phases.
+For example, the <code>compile</code> phase must execute after <code>compile-only</code> project dependencies have reached the <code>ready</code> phase.
+Maven 4 also allows to skip phases (in comparison to the old graph).
+For example, it's possible to <code>deploy</code> an artifact without <code>install</code>ing it to the user repository.</p>
+<p>For compatibility, the execution behavior is not really changed by default compared to Maven 3.
+In order to actually leverage the new tree-based lifecycle, the user has to enable the concurrent builder using
+<code>-b concurrent</code>.
+Running with the concurrent builder will allow finer grained dependency instead of the usual Maven 3 per-project
+dependency.
+With the usual builders and run <code>mvn verify</code>, a project will run up to the verify phase, before a dependent project can
+start being built, whereas the concurrent builder will allow a dependant project to be built as soon as the dependencies
+are at the <code>ready</code> phase.</p></section><section><a id="Pre-_and_post-phases.2C_ordering_of_executions"></a>
+<h4>Pre- and post-phases, ordering of executions</h4>
+<p>Every lifecycle phase now has a <code>before:</code> and an <code>after:</code> phase, allowing plugins to bind themselves to those.
+For example, if you want to set up test data before running your integration tests, you could execute tasks during the
+<code>before:integration-test</code> phase.</p>
+<p>If this is not enough, perhaps because you want to do multiple things inside the same phase, you can order each
+execution inside a phase by using square brackets with an integer at the end of the phase name.</p>
+<p>Example</p>
+
+<pre><code class="nohighlight nocode">before:integration-test[100]
+before:integration-test[200]
+</code></pre>
+<p><strong>Warning</strong>: The conceptual <code>pre-*</code> and <code>post-*</code> phases, which were only available for selected phases and had
+inconsistent naming, are deprecated.
+Don't use them!
+This becomes even more important if you are binding a plugin to the <code>post-*</code> phase of a lifecycle phase because the
+<code>pre-*</code> phase of the phase you really want to bind to does not exist, for example, binding to <code>process-resources</code> phase
+because there was no <code>pre-compile</code> phase.</p></section></section></section><section><a id="Maven_plugins.2C_security.2C_and_tools"></a>
+<h2>Maven plugins, security, and tools</h2><section><a id="Maven_plugins"></a>
+<h3>Maven plugins</h3>
+<p>As mentioned above, Maven 4 contains significant code and API updates, resulting in breaking changes for (very) old
+Maven plugins that have not been updated to use the recommended APIs.
+Major changes regarding plugins include a proper immutable plugin model together with a revised plugin API.
+The updated API provides hints as preparation for Maven 4.
+You can enable them by passing the following argument to your build: <code>-Dmaven.plugin.validation=verbose</code>.
+You should also only rely on the official Maven BOMs when developing plugins.
+If a plugin still relies on long-deprecated and now removed Plexus dependency injection, it will no longer work.
+It needs to be updated to use JSR-330 - see <a href="https://maven.apache.org/maven-jsr330.html" class="externalLink">Maven & JSR-330</a> for further information.</p>
+<p><strong>Advice</strong>: If you are maintaining a Maven plugin, you should test it with Maven 3.9.x.
+Pay close attention to upcoming warnings and update the plugin accordingly.</p></section><section><a id="Improved_encryption"></a>
+<h3>Improved encryption</h3>
+<p>Security is important, and storing unencrypted passwords is bad practice.
+Maven 3's password encryption had several serious issues and could more accurately be called “password obfuscation”.
+Maven 4 instead has a completely redone encryption system, based on Maven Encryption (<code>mvnenc</code>) - a standalone CLI tool.
+As of now, it provides functionally equivalent operations as Maven 3 (see <a href="https://maven.apache.org/guides/mini/guide-encryption.html" class="externalLink">“Maven: Password Encryption”</a>) but adds
+improvements like a <code>decrypt</code> functionality.
+A broad overview of the problems in Maven 3 and the solution in Maven 4 can be found in the
+article <a href="https://cstamas.org/blog/2024/09/handling-sensitive-data-in-maven/" class="externalLink">“Handling sensitive data in Maven”</a> by Maven maintainer Tamás Cservenák.</p></section><section><a id="Maven_Resolver"></a>
+<h3>Maven Resolver</h3>
+<p>The <a href="https://maven.apache.org/resolver/" class="externalLink">Maven Artifact Resolver</a> is a library for working with artifact repositories and dependency resolution.
+Maven 4 includes the new 2.0 release of this library, which contains more than 150 fixes, upgrades, and
+improvements, for example, a Java native HTTP-Client - thanks to raising the Java version requirement to JDK 17!
+Another major difference compared to Maven 3 is that in the new major version, the resolver is hidden behind the new
+Maven API and is no longer used directly by plugins.</p></section><section><a id="Maven_Shell"></a>
+<h3>Maven Shell</h3>
+<p>Each time you run an <code>mvn</code> command, the entire process chain is executed: booting Java, starting Maven, loading the
+configuration, performing the task, tearing down, and exiting — <strong>every single time</strong>.
+To improve performance and reduce build times, you can use the <a href="https://github.com/apache/maven-mvnd" class="externalLink">Maven Daemon</a> (<code>mvnd</code>), which manages a pool of
+resident Maven processes.
+With Maven 4, you can also take advantage of the newly defined “Maven Shell” (<code>mvnsh</code>), which keeps a single Maven
+process running for as long as the shell remains open.</p></section></section><section><a id="Issue_overview"></a>
+<h2>Issue overview</h2>
+<p>The Maven issue tracker provides a <a href="https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12316922&version=12346477" class="externalLink">full list of all resolved issues of Maven 4.0.0</a>.</p></section></section> </main>
+ </div>
+ </div>
+ <hr/>
+ <footer>
+ <div class="container-fluid">
+ <div class="row-fluid">
+ <p>© 2002â2025
+<a href="https://www.apache.org/">The Apache Software Foundation</a>
+</p>
+ </div>
+ </div>
+ </footer>
+ </body>
+</html>
\ No newline at end of file