Skip to content

Remove runtime dependency on log4j-core - #2343

Merged
Goooler merged 2 commits into
mainfrom
drop-log4j-core-dependency
Oct 25, 2026
Merged

Goooler merged 2 commits into
mainfrom
drop-log4j-core-dependency

Conversation

@Goooler

@Goooler Goooler commented Oct 25, 2026

Copy link
Copy Markdown
Member

Read and write Log4j2Plugins.dat files directly in Log4j2PluginsCacheFileTransformer instead of using Log4j's PluginCache, so Shadow no longer pulls log4j-core and its CVEs into users' build classpaths. The output stays byte-for-byte identical, which is verified against PluginCache in tests.

Closes #2060.


  • CHANGELOG's "Unreleased" section has been updated, if applicable.

Read and write `Log4j2Plugins.dat` files directly in
`Log4j2PluginsCacheFileTransformer` instead of using Log4j's `PluginCache`,
so Shadow no longer pulls `log4j-core` and its CVEs into users' build
classpaths. The output stays byte-for-byte identical, which is verified
against `PluginCache` in tests.

Closes #2060.
Comment thread build.gradle.kts Outdated
Co-authored-by: Zongle Wang <wangzongler@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues in the focused replacement, and the added tests check compatibility with Log4j; tests were not run.

No open issues 🎉

What changed in this PR

Removes Shadow’s runtime dependency on log4j-core, addressing #2060 while retaining Log4j plugin-cache merging and class relocation.

Changes:

  • Reads and writes Log4j2Plugins.dat directly, replacing Log4j’s PluginCache and temporary files.
  • Keeps Log4j as a test-only dependency and adds byte-for-byte compatibility checks.
  • Updates functional-test imports and documents the dependency removal.
File Description
src/​test/​kotlin/​com/​github/​jengelman/​gradle/​plugins/​shadow/​transformers/​Log4j2PluginsCacheFileTransformerTest.kt Adds format compatibility checks and adapts relocation tests.
src/​main/​kotlin/​com/​github/​jengelman/​gradle/​plugins/​shadow/​transformers/​Log4j2PluginsCacheFileTransformer.kt Implements direct cache parsing, merging, and serialization.
src/​functionalTest/​kotlin/​com/​github/​jengelman/​gradle/​plugins/​shadow/​transformers/​TransformersTest.kt Uses Shadow’s cache-path constant.
CHANGELOG.md Records the runtime dependency removal.
build.gradle.kts Moves Log4j from runtime to unit-test dependencies.

Review effort: Balanced

@Goooler
Goooler merged commit cf71351 into main Oct 25, 2026
8 checks passed
@Goooler
Goooler deleted the drop-log4j-core-dependency branch October 25, 2026 11:00
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.

Move "log4j shadow" to a separate plugin

2 participants