Shibu
Shibu

Reputation: 1542

SBT package to include only a few external jars but not all

Is there a way that I can use sbt package to include a few external jars but not all. I am aware about sbt assembly but that will include all the jars that is configured in build.sbt

Upvotes: 1

Views: 815

Answers (3)

Basant Gurung
Basant Gurung

Reputation: 1

unmanagedJars in Compile += file("lib/my.jar")

Upvotes: -1

Matthias Berndt
Matthias Berndt

Reputation: 4587

You can use the assemblyExcludedJar setting in the assembly plugin. There's an example in the sbt-assembly README:

assemblyExcludedJars in assembly := { 
  val cp = (fullClasspath in assembly).value
  cp filter {_.data.getName == "compile-0.1.0.jar"}
}

Upvotes: 0

Hitesh Tiwari
Hitesh Tiwari

Reputation: 39

In that case you have to give the dependencies without "provided" option and add "provided" to exclude the dependencies for packages in build.sbt file.

Example: Here I have given "provided" for spark-streaming dependency, which will not be included in my fat jar:

"org.apache.spark" %% "spark-streaming" % sparkVersion % "provided"

But pureconfig dependency package which will be included in my fat jar as I have not mentioned the "provided" keyword:

"com.github.pureconfig" %% "pureconfig" % "0.12.3"

Upvotes: 2

Related Questions