My project file structure looks like this:
- build.sbt
- lib
- project
- src
- target
- test
Inside lib
folder I have sub folders that contain additional jar files. How can I get SBT to recognize sub-folders or to treat jar files recursively?
EDIT:
thanks to @Jhonny Everson I am able to get this working. Here is how:
added the following line in my build.sbt
unmanagedJars in Compile <++= baseDirectory map { base =>
val baseDirectories = (base / "lib" / "mycustomlib" )
val customJars = (baseDirectories ** "*.jar")
customJars.classpath
}
Note that the base directory is where build.sbt is located.
if you put jars on lib folder, Sbt will use them automatically. You can use unmanagedJars
directive to specify multiple directories in which jar files can be found. See https://github.com/harrah/xsbt/wiki/Library-Management#manual-dependency-management
I wanted to implement something like vim's pathogen and here's what I came up with:
unmanagedJars in Compile ++= {
val libs = baseDirectory.value / "lib"
val subs = (libs ** "*") filter { _.isDirectory }
val targets = ( (subs / "target") ** "*" ) filter {f => f.name.startsWith("scala-") && f.isDirectory}
((libs +++ subs +++ targets) ** "*.jar").classpath
}
Using sbt 0.13.x or any typesafe-activator relying on it, this will check /lib
, /lib/*
and /lib/*/target/scala-*
for JARs and load them into the classpath. If the example isn't clear enough to understand what's going on, it might help to know that baseDirectory.value
, libs
, subs
and targets
are sbt.Pathfinder instances.