-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(singlejar): Add Log4j plugins cache combiner #22581
base: master
Are you sure you want to change the base?
feat(singlejar): Add Log4j plugins cache combiner #22581
Conversation
@sgowroji what question do I need to answer for "awaiting-user-response" to get removed? @softprops @jwilliams-ocient from #7330; does this help the issue for you? |
@stevebarrau Could you please take a look at the failing checks? |
659623f
to
d8130cb
Compare
@sgowroji PTAL. |
cc @cushon |
Ping @cushon |
@cushon Can you please take a look? |
@hvadehra @meteorcloudy for Blaze we don't need to support log4j, so supporting this isn't a priority for me. I also don't want to stand in the way of progress if you want to support this in Bazel. I left a note in #7330 about the idea of trying to make this kind of thing more pluggable, but there may not be great alternatives to doing it directly in singlejar. If that's something you want to pursue, perhaps the new 'combiner' here could be factored into a separate file and only wired up for Bazel. |
src/tools/singlejar/combiners.cc
Outdated
return nullptr; | ||
} | ||
|
||
void *outputEntryFromBuffer(const std::string filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of extracting this helper, would it be possible to share implementation with Concatenator
with composition, similar to what ManifestCombiner
does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Composed in e416b51
src/tools/singlejar/combiners.cc
Outdated
@@ -284,3 +295,152 @@ void *ManifestCombiner::OutputEntry(bool compress) { | |||
concatenator_->Append("\r\n"); | |||
return concatenator_->OutputEntry(compress); | |||
} | |||
|
|||
template<typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to move Log4J2PluginDatCombiner
into a separate file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted in 8e901f0
@cushon I would prefer to author this in Java to reuse the log4j merger logic from existing implementation. Ideally I agree with you if we could provide a set of custom combiners as configuration instead of having to add complexity/features in singlejar this would be very nice. Where could we start to pry open singlejar and allow external combiners to be configured? In the short term, if I address the comments, is this something that could live in singlejar until we rollout a configurability mechanism? |
@shs96c if this ends up being authorable in Java, would https://github.com/bazel-contrib/rules_jvm be a good home for this log4j jar combiner extension? |
|
58e985f
to
8e901f0
Compare
…uires compiler flag '/std:c++17'
3a95585
to
6ae3fb8
Compare
@cushon PTAL. |
In singlejar, add support for combining Log4j2 plugins cache file.
Log4j2 plugins are Java annotations collected by a compiler plugin into .dat files for Log4j2 runtime to find them fast. With correct dependency on a
java_plugin
, Bazel already runs the java plugin compiler correctly. The behavior is correct onbazel run
JAR, but not on_deploy.jar
fat jars.The silent clobbering of files in general, and the example of these Log4j2 .dat files in particular, is discussed in #7330.
I tested this fix in my project using Bazel 7.0.2, compiling
//src:java_tools_prebuilt.zip
, and overriding@remote_java_tools_darwin_arm64
and@remote_java_tools_linux
.