2012-09-15 00:08:35 +02:00
|
|
|
===================
|
|
|
|
|
Directory structure
|
|
|
|
|
===================
|
|
|
|
|
|
|
|
|
|
This page assumes you've :doc:`installed sbt <Setup>` and
|
|
|
|
|
seen the :doc:`Hello, World <Hello>` example.
|
|
|
|
|
|
|
|
|
|
Base directory
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
In sbt's terminology, the "base directory" is the directory containing
|
2013-07-29 13:27:17 +02:00
|
|
|
the project. So if you created a project `hello` containing
|
|
|
|
|
`hello/build.sbt` and `hello/hw.scala` as in the :doc:`Hello, World <Hello>`
|
|
|
|
|
example, `hello` is your base directory.
|
2012-09-15 00:08:35 +02:00
|
|
|
|
|
|
|
|
Source code
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
Source code can be placed in the project's base directory as with
|
2013-07-29 13:27:17 +02:00
|
|
|
`hello/hw.scala`. However, most people don't do this for real
|
2012-09-15 00:08:35 +02:00
|
|
|
projects; too much clutter.
|
|
|
|
|
|
|
|
|
|
sbt uses the same directory structure as
|
|
|
|
|
`Maven <http://maven.apache.org/>`_ for source files by default (all
|
|
|
|
|
paths are relative to the base directory):
|
|
|
|
|
|
2012-09-19 02:12:32 +02:00
|
|
|
.. code-block:: text
|
2012-09-15 00:08:35 +02:00
|
|
|
|
|
|
|
|
src/
|
|
|
|
|
main/
|
|
|
|
|
resources/
|
|
|
|
|
<files to include in main jar here>
|
|
|
|
|
scala/
|
|
|
|
|
<main Scala sources>
|
|
|
|
|
java/
|
|
|
|
|
<main Java sources>
|
|
|
|
|
test/
|
|
|
|
|
resources
|
|
|
|
|
<files to include in test jar here>
|
|
|
|
|
scala/
|
|
|
|
|
<test Scala sources>
|
|
|
|
|
java/
|
|
|
|
|
<test Java sources>
|
|
|
|
|
|
2013-07-29 13:27:17 +02:00
|
|
|
Other directories in `src/` will be ignored. Additionally, all hidden
|
2012-09-15 00:08:35 +02:00
|
|
|
directories will be ignored.
|
|
|
|
|
|
|
|
|
|
sbt build definition files
|
|
|
|
|
--------------------------
|
|
|
|
|
|
2013-07-29 13:27:17 +02:00
|
|
|
You've already seen `build.sbt` in the project's base directory. Other
|
|
|
|
|
sbt files appear in a `project` subdirectory.
|
2012-09-15 00:08:35 +02:00
|
|
|
|
2013-07-29 13:27:17 +02:00
|
|
|
`project` can contain `.scala` files, which are combined with
|
|
|
|
|
`.sbt` files to form the complete build definition.
|
2012-09-15 00:08:35 +02:00
|
|
|
See :doc:`.scala build definitions <Full-Def>` for more.
|
|
|
|
|
|
2012-09-19 02:12:32 +02:00
|
|
|
.. code-block:: text
|
2012-09-15 00:08:35 +02:00
|
|
|
|
|
|
|
|
build.sbt
|
|
|
|
|
project/
|
|
|
|
|
Build.scala
|
|
|
|
|
|
2013-07-29 13:27:17 +02:00
|
|
|
You may see `.sbt` files inside `project/` but they are not
|
|
|
|
|
equivalent to `.sbt` files in the project's base directory. Explaining
|
2012-09-15 00:08:35 +02:00
|
|
|
this will :doc:`come later <Full-Def>`, since you'll need
|
|
|
|
|
some background information first.
|
|
|
|
|
|
|
|
|
|
Build products
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
Generated files (compiled classes, packaged jars, managed files, caches,
|
2013-07-29 13:27:17 +02:00
|
|
|
and documentation) will be written to the `target` directory by
|
2012-09-15 00:08:35 +02:00
|
|
|
default.
|
|
|
|
|
|
|
|
|
|
Configuring version control
|
|
|
|
|
---------------------------
|
|
|
|
|
|
2013-07-29 13:27:17 +02:00
|
|
|
Your `.gitignore` (or equivalent for other version control systems)
|
2012-09-15 00:08:35 +02:00
|
|
|
should contain:
|
|
|
|
|
|
2012-09-19 02:12:32 +02:00
|
|
|
.. code-block:: text
|
2012-09-15 00:08:35 +02:00
|
|
|
|
|
|
|
|
target/
|
|
|
|
|
|
2013-07-29 13:27:17 +02:00
|
|
|
Note that this deliberately has a trailing `/` (to match only
|
|
|
|
|
directories) and it deliberately has no leading `/` (to match
|
|
|
|
|
`project/target/` in addition to plain `target/`).
|
2012-09-15 00:08:35 +02:00
|
|
|
|
|
|
|
|
Next
|
|
|
|
|
====
|
|
|
|
|
|
|
|
|
|
Learn about :doc:`running sbt <Running>`.
|