How do I specify a custom directory layout for an sbt project?
build, sbt
Solution
One can override a number of sbt's default directory locations. Here's an example that overrides the directory where sbt expects to find "unmanaged" dependencies/jar files:
unmanagedBase := baseDirectory.value / "custom-jars-directory"
(More examples related to depndencies in the sbt documentation.)
You can also configure the directories as specific to a particular "task"... E.g., to set the directory where test-case source code is, try:
scalaSource in Test := { (baseDirectory in Test)(_ / "test") }.value
And then your core application source code could be somewhere else, say under `src/`:
scalaSource in Compile := { (baseDirectory in Compile)(_ / "src") }.value
NOTE: For older versions of `sbt` you may need the following (now-deprecated) syntax:
unmanagedBase <<= baseDirectory { base => base / "custom-jars-directory" }
scalaSource in Compile <<= (baseDirectory in Compile)(_ / "src")
This syntax will not work in newer versions of `sbt` (since 0.13.13, I believe).
Problem
How do I specify a custom directory layout for an `sbt`-based project? I've been looking at the online `sbt` material, but I'm struggling to find this information... What I did find in the documentation were the default locations: - Sources in the base directory - Sources in `src/main/scala` and `src/main/java` - Tests in `src/test/scala` and `src/test/java` - Data files in `src/main/resources` and `src/test/resources` - Unmanaged jar-files in `lib/` How do I override these in the `build.sbt` file? My project structure is currently as follows: - Source in: `[workspace]/sandbox-scala/src/sbt/myFirst/` - Libraries in: `[workspace]/java-lib/common/lib/` Any help appreciated.