Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add an extra lib folder dependency to build sbt in a lift project

Tags:

scala

sbt

lift

I have an external java project that my lift project depends on. I have been able to add the dependency to the classes in that project by adding the following line to my sbt:

unmanagedClasspath in Compile += file("[Path to My Project]/classes")

But this project also has a lib folder with a set of jars that it references and I cannot figure out what the correct syntax should be to add these dependencies. Have tried the following but it does not work:

unmanagedJars in Compile += file("[Path to My Project]/lib/*.jar")

Any pointers greatly appreciated

Regards

Des

like image 263
user79074 Avatar asked Jun 05 '13 12:06

user79074


People also ask

How do we specify library dependencies in sbt?

The libraryDependencies key Most of the time, you can simply list your dependencies in the setting libraryDependencies . It's also possible to write a Maven POM file or Ivy configuration file to externally configure your dependencies, and have sbt use those external configuration files.

How do I add library dependencies?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build. gradle file. This declares a dependency on an Android library module named "mylibrary" (this name must match the library name defined with an include: in your settings.

Where are sbt dependencies stored?

If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.


1 Answers

You can use sbt's Path API to get all jars in your directory.

Edit: a shorter version using .classpath:

unmanagedJars in Compile ++= 
  (file("[Path to My Project]/lib/") * "*.jar").classpath

which is more or less equivalent to:

unmanagedJars in Compile ++= 
  Attributed.blankSeq((file("[Path to My Project]/lib/") * "*.jar").get)

(Attributed is necessary because unmanagedJars is a setting of type Seq[Attributed[File]] and not Seq[File])

like image 69
gourlaysama Avatar answered Sep 21 '22 12:09

gourlaysama