My project has dependency on an external jar. I have created a directory lib
and have copied the jar file into it. This is my build.sbt
:
name := "approxstrmatch" version := "1.0" scalaVersion := "2.10.4" unmanagedJars in Compile += file("lib/secondstring-20140729.jar") libraryDependencies+="org.apache.spark"%%"spark-core"%"1.0.0" resolvers += "AkkaRepository" at "http://repo.akka.io/releases/"
When I run clean
and package
, the external jar file does not get included in the generated jar file. Why?
This is the project layout:
project/build.sbt lib/ src/.....
You can right-click on the project, click on export, type 'jar', choose 'Runnable JAR File Export'. There you have the option 'Extract required libraries into generated JAR'.
Try this
libraryDependencies += "com.acme.common" % "commonclass" % "1.0" from "file:///Users/bwong/git/perf-tools/commonclass/target/scala-2.11/commonclass_2.11-1.0.jar"
I "sbt package" the common classproject and then just add that library dependency in my build.sbt in the dependent projects.
Thanks to http://flummox-engineering.blogspot.com/2014/06/sbt-use-jar-file-for-librarydependencies.html for this hack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With