Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
686 views
in Technique[技术] by (71.8m points)

sbt - How to include an external jar file into the jar with package?

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/.....
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...