0

Given a scala project that depends on a library with java multi-release dependencies and targets java 8 only, sbt-assembly will log multiple warnings similar to

Fully-qualified classname does not match jar entry:
  jar entry: META-INF/versions/9/org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.class
  class name: org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.class
Omitting META-INF/versions/9/org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.class.

What is the correct way to deal with these warnings and skip META_INF/versions/* that are not needed for jvm 8?

Klugscheißer
  • 1,575
  • 1
  • 11
  • 24

1 Answers1

1

As best I can tell this must be solved using assembly / assemblyShadeRules via something like:

assembly / assemblyShadeRules := Seq(
   /* Sadly patterns are not simple regex so we can't have
    * a single "OR" pattern or something similar and must 
    * enumerate all the possible version directories. Additionally,
    * `/` is not a valid pattern char so `.` must be used.
    */
    ShadeRule.zap("**module-info").inAll,
    ShadeRule.zap("*.versions.9.**").inAll,
    ShadeRule.zap("*.versions.11.**").inAll,
    ShadeRule.zap("*.versions.15.**").inAll
)

Merely setting assemblyMergeStrategy via something like

assembly / assemblyMergeStrategy := {
    case x if x.endsWith("module-info.class") => MergeStrategy.discard // Don't care about this for java8 so nuke it
    case PathList("META-INF", "versions", xs @ _*) => MergeStrategy.discard
}

is not enough to remove the warnings as they originate from the call to the pants based jarjar shader which is run before the the merging strategies are applied.

Klugscheißer
  • 1,575
  • 1
  • 11
  • 24