logging-log4j2 icon indicating copy to clipboard operation
logging-log4j2 copied to clipboard

Migrate to Maven 4

Open ppkarwasz opened this issue 6 months ago • 4 comments

With the upcoming release of Maven 4.0.0, we should begin evaluating the compatibility of its release candidates with Log4j. Maven 4 introduces several significant changes that are highly relevant to our build and release process.

Key Benefits for Log4j

1. Separation of Build and Consumer POMs

Maven 4 formally introduces a clean separation between the build POM (used during the build process) and the consumer POM (published to Maven Central).

Currently, we use the Flatten Maven Plugin to publish a simplified version of our log4j-bom, which removes build-related metadata and retains only the dependency management section. However, this approach is fragile—stripping too much information can lead to broken or unresolvable artifacts. This has already contributed to several issues, including:

  • apache/logging-parent#37
  • #3758
  • #3779

Migrating to Maven 4’s Consumer POM model would eliminate the need for these manual workarounds by making the separation between build and published metadata a first-class feature, managed directly by Maven.

2. CI-Friendly Versioning

Maven 4 introduces support for automatic versioning of submodules in multi-module builds. This would offer a more robust alternative to our current usage of the revision property and Flatten Maven Plugin, further simplifying our build process.

ppkarwasz avatar Jun 25 '25 10:06 ppkarwasz

This should be an interesting build update. IntelliJ has some Maven 4 support now, so IDEs aren't a blocker. Do we still want to use the XML format, or is there a better format available in Maven 4?

jvz avatar Aug 11 '25 20:08 jvz

We probably want to upgrade to the 4.1.0 XML schema for POM files.

I tried that a couple of months ago, but I encountered some problems with dependency version resolution, which ended up triggering the requireUpperBoundDeps Maven Enforcer rule. I didn't investigate this further.

ppkarwasz avatar Aug 11 '25 20:08 ppkarwasz

Please stick to XML – logging-parent has some XML-specific machinery over pom.xml. Slightly related: our changelog entry file format is in XML too.

vy avatar Aug 12 '25 12:08 vy

Please stick to XML – logging-parent has some XML-specific machinery over pom.xml. Slightly related: our changelog entry file format is in XML too.

That's a good point. We have sufficient XML tooling in place that it makes sense to keep using.

jvz avatar Aug 13 '25 17:08 jvz