rathika s
rathika s

Reputation: 17

Packaging Jar using SBT assembly

How do packaging a jar by selected scala classes using SBT assembly. While using SBT full project is created as jar. Is there a way to exclude the classes? Please help .

Upvotes: 0

Views: 275

Answers (1)

chengpohi
chengpohi

Reputation: 14217

You can use assemblyMergeStrategy with MergeStrategy.discard to discard to the classes that you want, like:

assemblyMergeStrategy in assembly := {
  case PathList("javax", "servlet", xs @ _*)         => MergeStrategy.first
  case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
  case "application.conf"                            => MergeStrategy.concat
  case "unwanted.txt"                                => MergeStrategy.discard
  case x =>
    val oldStrategy = (assemblyMergeStrategy in assembly).value
    oldStrategy(x)
}

Reference:

https://github.com/sbt/sbt-assembly#merge-strategy

Upvotes: 1

Related Questions