I'm having quite a few troubles pointing at a custom directory for Scala source-files in SBT.
I would like sbt to compile scala-files from a given directory instead of the regular src/main/scala
directory.
I have tried both defining a .sbt and .scala project files, setting baseDirectory
, scalaSource
(and scalaSource
s in the .scala file). I've also toyed around with everything from system-absolute to relative paths but nothing seems to work. It cannot locate any .scala file under the specified directory.
What are the proper ways to handle this?
In sbt's terminology, the “base directory” is the directory containing the project. So if you created a project hello containing /tmp/foo-build/build. sbt as in the sbt by example, /tmp/foo-build is your base directory.
Solution. You can use both managed and unmanaged dependencies in your SBT projects. 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.
sbt. Therefore, this folder contains all the files needed for building build. sbt. project/build. properties — this file contains build definition of build.
sbt file contains the instructions on how to build your Scala program. The project folder contains sbt configurations and settings, while src contains all your source code. sbt creates the target folder after you compile your code; it includes the JVM bytecode of your application.
Try this in build.sbt:
scalaSource in Compile <<= (sourceDirectory in Compile)(_ / "foo")
This will result in a directory src/main/foo for Scala sources. If you want to use some arbitrary directory, go for this:
scalaSource in Compile := file("/Users/heiko/tmp")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With