Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Scala sources directory in SBT

Tags:

scala

sbt

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?

like image 648
Jens Egholm Avatar asked Apr 12 '12 20:04

Jens Egholm


People also ask

Where is sbt folder?

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.

Where are sbt dependencies stored?

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.

What is .sbt folder?

sbt. Therefore, this folder contains all the files needed for building build. sbt. project/build. properties — this file contains build definition of build.

What does the src folder contain in an sbt project?

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.


1 Answers

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")
like image 185
Heiko Seeberger Avatar answered Oct 10 '22 19:10

Heiko Seeberger