Skip to content

Conversation

@MartyIX
Copy link
Contributor

@MartyIX MartyIX commented Jul 15, 2025

This is a PR that addresses #350 (comment).

Now, this command

export LOG4J_VERSION=2.25.1; ./gradlew :log4j-samples-gradle-metadata:build

leads to

Errors occurred while building effective model from /Users/me/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.25.1/bac75b77765d4eb74e4122d34000d7892c6605fa/log4j-api-2.25.1.pom:
        'dependencies.dependency.version' for com.google.errorprone:error_prone_annotations:jar must be a valid version but is '${error-prone.version}'. in org.apache.logging.log4j:log4j-api:2.25.1

BUILD SUCCESSFUL in 648ms

(Note that the build is successful but the error is still reported. So in a way, the error seems non-blocking but honestly I would not rely on it.)

cc @ppkarwasz

MartyIX and others added 2 commits August 30, 2025 18:24
Use Gradle 8.x’s internal logging API to abort the build if any log event of severity WARN or higher is emitted. This helps prevent harmless warnings from blocking Log4j adoption in strict environments.

⚠️ This approach relies on unsupported APIs and may break with Gradle 9.x, but it is currently the most effective option.
@ppkarwasz
Copy link
Contributor

I had to hook into Gradle’s internal logging system to make the build fail on warnings/errors, and it worked 🎉.
This relies on unsupported APIs, so it may break in a future Gradle major release, but since we don’t plan to upgrade Gradle anytime soon it’s an acceptable trade-off for now.

In fact, the CI failure here is proof that the check is working correctly:

 * Build failed due to 1 WARN/ERROR log event(s):
Error:  Errors occurred while building effective model from /home/runner/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.26.0-SNAPSHOT/89185e886b8a01f7bd7deadcb0dccd0fc916c7/log4j-api-2.26.0-SNAPSHOT.pom:
    'dependencies.dependency.version' for com.google.errorprone:error_prone_annotations:jar must be a valid version but is '${error-prone.version}'. in org.apache.logging.log4j:log4j-api:2.26.0-SNAPSHOT

Thanks again for your contribution, @MartyIX 🙏

@ppkarwasz ppkarwasz requested a review from vy August 30, 2025 17:11
@MartyIX
Copy link
Contributor Author

MartyIX commented Aug 30, 2025

Thanks again for your contribution, @MartyIX 🙏

I'm very happy that my contribution helped a bit :)

@vy vy changed the title Gradle: Repro for issue 3779 Gradle: Reproducer for apache/logging-log4j2#3779 Sep 1, 2025
@vy vy merged commit 38165d2 into apache:main Sep 1, 2025
10 of 11 checks passed
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.

3 participants