Search code examples
scalasbtlift

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


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


Solution

  • 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])