Awesome
sbt-assembly-log4j2
Problem: When including several projects that include log4j2
plugins,
sbt-assembly
will encounter multiple versions of the Log4j2Plugins.dat
cache file that it won't be able to reconcile.
Solution: Log4j2 provides a PluginCache
class that creates consistent,
serialisable cache from multiple different ones.
This plugin provides a simple function to merge those files in a safe way.
Usage (sbt 1.3+)
project/plugins.sbt:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
addSbtPlugin("com.michaelpollmeier" % "sbt-assembly-log4j2" % "1.1.3")
build.sbt
assembly/assemblyMergeStrategy := {
case "META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat" =>
sbtassembly.Log4j2MergeStrategy.plugincache
}
Latest version of sbt-assembly: see https://github.com/sbt/sbt-assembly#setup
Credits
- Stathis Charitos for the idea and creating the first version. Unfortunately it's unmaintained and only available for a outdated sbt and sbt-assembly versions.
- Ben Reyes for providing an upgrade PR that got incorporated here.