Reputation: 1096
This may be an elementary question, but I'm having a hard time finding any relevant links. (Plus I don't know Java so I might be starting a bit behind.)
I want to understand how to add local packages to a Scala project in sbt. For instance, where do I put the files, what do I name them, and how must I modify build.sbt?
Let's say I'm starting with a tutorial project that I already checked out from Git. I just want to add more packages, for the purpose of organizing code into different packages.
I've seen many links to Scala tutorials, but the build.sbt and packages are already set up for me.
When I Google on phrases like "add new package to sbt project" I get back pages about IntelliJ IDEA, or Eclipse, or there's one page that explains how to "package a Scala project for deployment," which seems to be a different meaning of the word "pacakge."
Upvotes: 3
Views: 1816
Reputation: 649
SBT follows a similar directory structure to Maven projects. Inside your project, your source files should live under
src/main/scala
src/main/resources (for text, images or other non-source code resources)
Your test source files should live under
src/test/scala
To add a new package you simply create a directory structure in your scala source directory. For example, if you need to create a package called mypackage
with a sub package stuff
it would live here:
src/main/scala/mypackage/stuff
All Scala source files inside stuff
would need to start with the line package mypackage.stuff
Upvotes: 1