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

Shading doesn't insert unmanaged dependencies appropriately in the jar #200

Closed
cspinetta opened this issue Feb 13, 2016 · 3 comments
Closed

Comments

@cspinetta
Copy link

I have a jar under the folder /lib and I'm shading it with assemblyShadeRules. Assembly renames the imports correctly but leaves the unmanaged jar's class in the root of the resulting jar.

This is my SBT config:

lazy val assemblySettings = Seq(
    assemblyJarName in assembly := s"agent.jar",
    assemblyOption in assembly := (assemblyOption in assembly).value.copy(cacheUnzip = false),
    packageOptions <+= (name, version, organization) map { (title, version, vendor) =>
      Package.ManifestAttributes(
        "Created-By" -> "Simple Build Tool",
        "Built-By" -> System.getProperty("user.name"),
        "Build-Jdk" -> System.getProperty("java.version"),
        "Premain-Class" -> "agent.Bootstrap",
        "Agent-Class" -> "agent.Bootstrap",
        "Can-Redefine-Classes" -> "true",
        "Can-Retransform-Classes" -> "true")
    },
    assemblyShadeRules in assembly := Seq(
      ShadeRule.rename("net.bytebuddy.**" -> "agent.libs.@0").inAll,
      ShadeRule.rename("ch.qos.logback.core.**" -> "agent.libs.@0").inAll,
      ShadeRule.rename("ch.qos.logback.classic.**" -> "agent.libs.@0").inAll,
      ShadeRule.rename("org.slf4j.**" -> "agent.libs.@0").inAll
    )
    // logLevel in assembly := Level.Debug,
    // unmanagedJars in Compile += file("agent/lib/byte-buddy-1.2.0.jar")
  ) ++ addArtifact(artifact in(Compile, assembly), assembly) ++ (test in assembly := {})

  artifact in (Compile, assembly) := {
    val art = (artifact in (Compile, assembly)).value
    art.copy(`classifier` = Some("assembly"))
  }

Tell me if I can provide some more specific example.

@damdev
Copy link

damdev commented Feb 3, 2017

Seems that the condition on the filter don't returns true when the ShadeRule was expecting to apply for all, because an unmanaged jar, don't have metadata, so jar.metadata.get(moduleID.key) returns None.

https://github.com/sbt/sbt-assembly/blob/master/src/main/scala/sbtassembly/Assembly.scala#L204

val jarRules = shadeRules .filter(r => jar.metadata.get(moduleID.key).exists(r.isApplicableTo))

damdev added a commit to damdev/sbt-assembly that referenced this issue Feb 3, 2017
@cspinetta
Copy link
Author

Excellent @damdev !!!
I'll be very fine with this fix ! =)

eed3si9n added a commit that referenced this issue Feb 15, 2017
Fix to #200 match ShadeRule forAll on unmanaged libs
@cspinetta
Copy link
Author

Fixed by #200 PR

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

No branches or pull requests

2 participants