Search code examples
scalasbtintellij-14

Scala source external to SBT project folder


When creating an SBT scala project in ItelliJ, it wants me to put all source code in the src/main/scala folder of the project folder. However, I want to put the source code somewhere else independent or particular projects, build-tools, IDEs, etc.

How do I tell it to get the source from arbitrary locations?


Solution

  • You can use the following settings to change the location where SBT looks for your Scala sources:

    // Change Scala source directory. Default is:
    // scalaSource in Compile := baseDirectory.value / "src" / "main" / "scala"
    scalaSource in Compile := file("<Path to your sources...>")
    
    // Change Scala test source directory. Default is:
    // scalaSource in Test := baseDirectory.value / "src" / "test" / "scala"
    scalaSource in Test := file("<Path to your test sources...>")
    

    For further information (including how to specify other source, library and resource directories), refer to the official SBT documentation for customizing paths.