sbt-scapegoat icon indicating copy to clipboard operation
sbt-scapegoat copied to clipboard

Do not include scapegoat class files in assembled jar

Open tekumara opened this issue 7 years ago • 10 comments

When I add the scapegoat plugin

addSbtPlugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "1.0.4")

Its class files are being included in my assembly when I run sbt assembly.

eg:

assembly [info] Including from cache: slf4j-api-1.7.5.jar [info] Including from cache: logback-classic-1.0.13.jar [info] Including from cache: scaldi_2.11-0.4.jar [info] Including: scala-xml_2.11-1.0.2.jar [info] Including from cache: config-1.2.1.jar [info] Including from cache: scalac-scapegoat-plugin_2.11-1.0.0.jar [info] Including from cache: logback-core-1.0.13.jar

tekumara avatar Mar 09 '17 22:03 tekumara

Any update on this? Almost 2MB are added into the fat jar for nothing, requiring a custom assembly merge strategy.

lomigmegard avatar Aug 07 '17 11:08 lomigmegard

Someone will need to make a pr as I don't know enough about SBT to fix it.

sksamuel avatar Aug 07 '17 11:08 sksamuel

@sksamuel I will try to have a look in my spare time then ;)

lomigmegard avatar Aug 07 '17 11:08 lomigmegard

Thanks.

sksamuel avatar Aug 07 '17 12:08 sksamuel

FWIW, this is the approach I took in my assembly configuration to get around this:

assemblyExcludedJars in assembly := {
  val cp = (fullClasspath in assembly).value
  // exclude the scapegoat plugin that is sneaking into the assembled jar
  cp filter {_.data.getName.matches("scalac-scapegoat-plugin.*\\.jar")}
}

kmudrick avatar Aug 31 '17 17:08 kmudrick

+1

ikr0m avatar Sep 15 '17 12:09 ikr0m

This should be fixed by #58 now released in v1.0.8. scalac-scapegoat-plugin is not included by assembly anymore.

dbast avatar Dec 29 '17 22:12 dbast

If I try using 1.0.8 I now get the opposite problem:

[error] java.lang.Exception: Fatal: scalac-scapegoat-plugin not in libraryDependencies (Vector(...big long list of dependencies...))
[error] 	at com.sksamuel.scapegoat.sbt.ScapegoatSbtPlugin$.$anonfun$projectSettings$4(ScapegoatSbtPlugin.scala:67)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42)
...

ashleymercer avatar Jan 09 '18 13:01 ashleymercer

@ashleymercer I had the same problem on my project (scala 2.11.12, sbt 1.0.4, sbt-scapegoat 1.0.8) and had to add the dependency "com.sksamuel.scapegoat" %% "scalac-scapegoat-plugin" % "1.3.3" and still filter it in the assembly.

ghost avatar Jan 09 '18 13:01 ghost

I've same issue as @ashleymercer with 1.0.8 version. With 1.0.7 everything is ok. To reproduce the issue, run from console:

> sbt
> scapegoat

ikr0m avatar Jan 10 '18 04:01 ikr0m