Search code examples
scalaintellij-ideasbt

custom folder structure in sbt for scala


The default folder Structure of SBT is like this:

src
  - main
      - scala
  - test
      - scala

But I want to have a custom folder structure, something like this:

src
  - main
  - test

So my question is:

How can I customize my build.sbt file, to have a custom folder structure and have Intellij Idea recognize the new structure?


Solution

  • According to https://www.scala-sbt.org/1.x/docs/Howto-Customizing-Paths.html, you would need to apply the following in your build.sbt:

    Compile / scalaSource := baseDirectory.value / "src/main"
    
    Test / scalaSource := baseDirectory.value / "src/test"
    

    I have not tried this, so not sure if this works as expected nor how far Intellij Idea supports this (though I'd expect it to fully support this).