sbt / sbt-onejar

Packages your project using One-JAR™
MIT License
268 stars 45 forks source link

Excluding jars #11

Closed shuttj closed 12 years ago

shuttj commented 12 years ago

Is there a way to exclude certain lib jars? For example, I don't want to include the scala-library.jar since I am using this in a java only project. Also, I have a library that is needed for compilation only and not at runtime.

shuttj commented 12 years ago

Ok, I figured out how to exclude the scala-library.jar, but still not sure how to exclude a dependency marked as compile.

retronym commented 12 years ago

You can do something like:

mappings in oneJar <<= (mappings in oneJar).map { (old: Seq[(File, String)] =>
  old.filterNot(_._1.getName == "excluded.jar")
}
huahang commented 11 years ago

In which file shall I place these lines?

mappings in oneJar <<= (mappings in oneJar).map { (old: Seq[(File, String)] =>
  old.filterNot(_._1.getName == "excluded.jar")
}
eric-aldinger commented 8 years ago

I found the above example did not work because of the unmatched parenthesis in front of the var old: Below works for excluding scoverage when it is added to plugins.sbt.

mappings in oneJar <<= (mappings in oneJar).map { depends: Seq[(File, String)] => depends.filterNot(_._1.getName == "scalac-scoverage-runtime_2.11-1.2.0.jar") }

For declared dependancies in your build sbt you can append % "test" like protobuffs and ScalaTest below

libraryDependencies` ++= Seq( "org.json4s" %% "json4s-native" % "3.4.1", "org.scalaj" %% "scalaj-http" % "2.3.0", "com.rabbitmq" % "amqp-client" % "3.6.5", "com.google.protobuf" % "protobuf-java" % "3.1.0" % "test", "org.scalatest" %% "scalatest" % "3.0.0" % "test")