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

META-INF/javax.annotation.processing.Processor is included empty when shading is enabled - log4j #490

Open
yannis-nt opened this issue Dec 29, 2022 · 2 comments

Comments

@yannis-nt
Copy link

yannis-nt commented Dec 29, 2022

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.

@yannis-nt yannis-nt changed the title META-INF/javax.annotation.processing.Processor is included empty when shading is enabled META-INF/javax.annotation.processing.Processor is included empty when shading is enabled - log4j Dec 29, 2022
@khujo
Copy link

khujo commented Jun 15, 2023

I'm having the same issue. Note that this only happens on Windows. Building on Linux produces the correct files in the jar.

@bartektartanus
Copy link

Any progress on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants