Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transitive compileOnlyApi (requires static) dependencies #3450

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

jjohannes
Copy link

This pull requests adds compileOnlyApi dependencies (Gradle Module Metadata) and requires static (module-info) for all annotation libraries used in Log4j. See #3437 for details.

The following example can be used to test the effects of the change in a Gradle build on a locally built snapshot:
https://github.com/jjohannes/gradle-demos/tree/main/log4j-metadata

Checklist

  • Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise
  • ./mvnw verify succeeds (if it fails due to code formatting issues reported by Spotless, simply run ./mvnw spotless:apply and retry)
  • Non-trivial changes contain an entry file in the src/changelog/.2.x.x directory
  • Tests for the changes are provided
  • Commits are signed (optional, but highly recommended)

@vy
Copy link
Member

vy commented Feb 10, 2025

@jjohannes, I've just released logging-parent version 12.0.0. It contains breaking changes touching these dependencies. dependabot should automatically update logging-parent version in /pom.xml. Would you mind keeping an eye on it, and once the update kicks in, make necessary adjustments to this PR, please?

@vy
Copy link
Member

vy commented Feb 10, 2025

@ppkarwasz, shall we also add a test for this to log4j-samples?

Copy link

github-actions bot commented Feb 10, 2025

Job Requested goals Build Tool Version Build Outcome Build Scan®
build-macos-latest clean install 3.9.8 Build Scan PUBLISHED
build-ubuntu-latest clean install 3.9.8 Build Scan PUBLISHED
build-windows-latest clean install 3.9.8 Build Scan PUBLISHED
Generated by gradle/develocity-actions

@jjohannes jjohannes force-pushed the 3437-transitive-compile-time-dependencies branch from 7a01da7 to ae8af12 Compare February 20, 2025 10:46
@ppkarwasz
Copy link
Contributor

@ppkarwasz, shall we also add a test for this to log4j-samples?

What test do you have in mind? Do we test that a certain dependency is in the Gradle compileClasspath configuration, but is not in the Gradle runtimeClasspath?

@jjohannes
Copy link
Author

@vy I rebased the PR and re-tested. I also checked the changes in logging-parent:12.0.0 - there were no conflicts.

If it fits, the sample Gradle project I created could be moved to log4j-samples. I added a check that asserts what is ending up on the classpaths if you only add the log4j-api. So running ./gradlew build on that sample would be a quite good "end-to-end" test for the metadata publishing.

@vy
Copy link
Member

vy commented Feb 20, 2025

If it fits, the sample Gradle project I created could be moved to log4j-samples. I added a check that asserts what is ending up on the classpaths if you only add the log4j-api. So running ./gradlew build on that sample would be a quite good "end-to-end" test for the metadata publishing.

@jjohannes, sounds plausible, thanks! We can run ./gradlew build either as a part of the integration-test.yaml workflow, or add it under a Maven module and run the command (using antrun-maven-plugin?), etc. @ppkarwasz, WDYT?

@ppkarwasz
Copy link
Contributor

@jjohannes, sounds plausible, thanks! We can run ./gradlew build either as a part of the integration-test.yaml workflow, or add it under a Maven module and run the command (using antrun-maven-plugin?), etc. @ppkarwasz, WDYT?

I would prefer not to use antrun-maven-plugin, lets have a separate Gradle run instead. We could think about merging some jobs in integration-test.yaml workflow. Currently we have:

  1. a Maven-based run for most of the example modules.
  2. a Maven-based run for the GraalVM test.
  3. a Gradle-based run for the Android test.

Since 1 and 2 only differ by the JDK used, we could use the GraalVM JDK for both and merge them.
I would be also nice to merge the new test module with the Android test, although I don't how to properly do it.

@jjohannes
Copy link
Author

What you could do is rename workflows/android-reusable-test.yaml to something like gradle-tests.yaml.

Then you can add another step that runs Gradle against the new example similar to this one that runs the Android example.

If that sounds like a good way forward to you, I can provide a (Draft) PR with the new example.

@ppkarwasz
Copy link
Contributor

If that sounds like a good way forward to you, I can provide a (Draft) PR with the new example.

Sounds good to me.

@vy
Copy link
Member

vy commented Feb 21, 2025

@jjohannes, I liked this proposal. Looking forward to your PR.

Note that both @ppkarwasz and I are swamped with work at the moment. Please be patient while waiting for feedback and/or reviews.

@jjohannes
Copy link
Author

Here is the PR for the samples repo: apache/logging-log4j-samples#279
Hope I did not miss anything important there.

@vy no problem. There is no urgency from my side. Let me know if I can help with anything else.

@jjohannes jjohannes force-pushed the 3437-transitive-compile-time-dependencies branch from ae8af12 to 6d5f2db Compare March 4, 2025 14:17
Copy link
Member

@vy vy left a comment

Choose a reason for hiding this comment

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

@jjohannes, thanks so much for the fix!

@ppkarwasz, changes LGTM. Would you mind also skimming through, please?

Copy link
Contributor

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

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

Looks good to me.

There is one missing annotation library and we are good to go!

biz.aQute.bnd.annotation,
com.google.errorprone.annotations,
com.github.spotbugs.annotations,
org.osgi.annotation.bundle
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add org.osgi.annotation.versioning too?

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