Skip to content

Conversation

@ppkarwasz
Copy link
Contributor

This adds a new log4j-api-to-slf4j bridge based on log4j-to-slf4j from the 2.x branch of Log4j.

mattsicker and others added 30 commits November 6, 2024 12:38
  - Also added component names where one wasn't there.
  - Using a lock in log4j-api (ProviderUtil) has prevented the need for this hack in OSGi.
complains. POM inheritance does not work like I thought it did!
vy and others added 26 commits November 6, 2024 12:40
- `/pom.xml` is moved to `/log4j-parent/pom.xml`
- `/log4j-bom/pom.xml` is moved to `/pom.xml`
- Implements the BOM organization described by Maven[1].
  That is, `parent` inherits from `bom`.
- Takes advantage of `flatten-bom` provided by `logging-parent`
- Identical scheme to the one found in `-tools` and `-transformation`

[1] https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms
There are many modules that do not depend on `log4j-core` and they can
be easily built without it on the processor path.
Since the split between modules that have Log4j Core plugins and those
that don't is about 50/50, it is more proper to add `log4j-core` to some
modules instead of removing it from others (and copy/paste all other
options).
In order to prevent API breaking changes, this:
 * adds [`bnd-baseline-maven-plugin`](https://github.com/bndtools/bnd/tree/master/maven-plugins/bnd-baseline-maven-plugin),
 * fix the API changes that would require a major version bump,
 * set the OSGi version of each packages to `2.20.1` or `2.21.0`,
   depending on the kind of changes the package underwent since the
   `2.20.0` release.
Most of our modules with a transitive dependency on `slf4j-api` used
version 1.7.36, while `log4j-slf4j-impl` used version 1.7.25 (due to a
breaking change in `slf4j-ext`) and `log4j-slf4j2-impl` used version
2.0.x.

This PR simplifies this configuration by:
 * switching `log4j-slf4j-impl` to use version 1.7.36 of `slf4j-api` and
   version 1.7.25 of `slf4j-ext`,
 * removing the need of `slf4j-ext` where applicable,
 * switching all the other modules to SLF4J 2.x,
 * modernizing the `log4j-to-slf4j` tests to use JUnit 5 instead of
   JUnit 4.
Due to the upgrade from SLF4J 1.7.x to 2.x, the JPMS and OSGi
descriptors of `log4j-to-slf4j` suffer from these shortcomings:

 * the JPMS descriptor uses a filebased `slf4j-api` module name (instead
   of `org.slf4j`,
 * the OSGi descriptor accepts a restricted range of SLF4J versions: [2,
   3). Since `slf4j-api` 2.x is technically just a minor version update
   of `slf4j-api` 1.7.x, we should use an extended range of [1.7, 3).

Closes #1983.
BND 7.x supports multi-release JARs, so we can remove many manual
overrides of module names.

We also **add** an override from `disruptor` to
`com.conversantmedia.disruptor`, since new (Java 11 based) versions of
`com.conversantmetida:disruptor` have a JPMS descriptor.
By removing the reflective instantiation of `LoggerContextFactory` and
`ThreadContextMap`, we make `log4j-to-jul` and `log4j-to-slf4j` more
GraalVM-friendly.
Bumps org.slf4j:slf4j-api from 2.0.9 to 2.0.16.

---
updated-dependencies:
- dependency-name: org.slf4j:slf4j-api
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Piotr Karwasz <[email protected]>
- Make `StringArray` the default thread context map
- Remove `CopyOnWriteSortedArrayThreadContextMap`
- Move `GarbageFreeSortedArrayThreadContextMap` to `log4j-core`
This adds a Groovy script that fails the build
if any optional JPMS module has the `transitive` qualifier.

We remove the `transitive` modifier from all optional dependencies.

Closes #2929.

Co-authored-by: Volkan Yazıcı <[email protected]>
@ppkarwasz ppkarwasz marked this pull request as ready for review December 23, 2024 08:39
@ppkarwasz ppkarwasz merged commit 3b8acf7 into main Dec 23, 2024
6 checks passed
@ppkarwasz ppkarwasz deleted the feature/log4j-api-to-slf4j branch December 23, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.