A play project has a "project" folder like this:
I always thought this is just one of those life mysteries that I shouldn't think too much about, but today my curiosity got the best of me.
Googling gave me this which mentions that the top-level "project" folder is for sbt configuration. I wonder why they didn't call that ".sbt" a la ".git" and why there is still a file "build.sbt" outside that folder, but I suppose there is no fun in making things actually make sense.
It also doesn't mention why it contains another "project" folder inside it.
Why is there a nested "project" folder?
A project is defined by declaring a lazy val of type Project. For example, : lazy val util = (project in file("util")) lazy val core = (project in file("core")) The name of the val is used as the subproject's ID, which is used to refer to the subproject at the sbt shell.
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.
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.
http://www.scala-sbt.org/0.13/tutorial/Organizing-Build.html:
build.sbt conceals how sbt really works. sbt builds are defined with Scala code. That code, itself, has to be built. What better way than with sbt?
The project directory is another build inside your build, which knows how to build your build. To distinguish the builds, we sometimes use the term proper build to refer to your build, and meta-build to refer to the build in project. The projects inside the metabuild can do anything any other project can do. Your build definition is an sbt project.
And the turtles go all the way down. If you like, you can tweak the build definition of the build definition project, by creating a project/project/ directory.
SBT is recursive. It defines build properties for your project with scala code. Where to place scala code? To the another project inside the current project. But if the project definition itself is a proper project then it can be configured with another sbt configuration. And so on. Scala guys like recursive structures.
You can change scala compiler version, scala compiler options for nested (in meta sense) projects. It probably can change the way the metaproject is interpreted and that can affect the upmost project.
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