sbt-assembly
sbt-assembly copied to clipboard
META-INF/javax.annotation.processing.Processor is included empty when shading is enabled - log4j
Hello,
to reproduce I create a simple sbt project with.
sbt new scala/hello-world.g8
Any sbt-assembly version >= 1.0.0 has the issue.
In the build.sbt
:
scalaVersion := "2.12.12"
name := "hello-world"
version := "1.0"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
libraryDependencies += "org.apache.logging.log4j" % "log4j-core" % "2.17.1"
assembly / assemblyMergeStrategy := {
// As an example, keep services but discard all the rest
case PathList("META-INF", "services", xs @ _*) => MergeStrategy.first
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
// Randomly shade something - if your remove this, the issue is not re-produced
assembly / assemblyShadeRules := Seq(
ShadeRule.rename("scala.collection.compat.**" -> "shadecompat.@1").inAll
)
In the produced hello-world-assembly-1.0.jar
file \META-INF\services\javax.annotation.processing.Processor
is empty.
To my point of view this is bug, because that file is not empty in the originating log4j-core-2.17.1.jar
.
To "fix" this issue, I can either change the plugin version to an older one, like 0.14.10
, or remove the shading rules.
Additonal files: In my project that produces an 160MB .jar file, I have the same issue with META-INF\org.apache.logging.log4j.util.PropertySource
. Interestingly, other javax.*
or org.apache.logging.log4j.*
files are correctly included.
I'm having the same issue. Note that this only happens on Windows. Building on Linux produces the correct files in the jar.
Any progress on this issue?