mirror of https://github.com/sbt/sbt.git
avoid "basic" and "full" terminology
No need to add terminology; just say .sbt and .scala files.
parent
fd29e86322
commit
27d489026e
|
|
@ -1,6 +1,6 @@
|
|||
[Keys]: http://harrah.github.com/xsbt/latest/sxr/Keys.scala.html
|
||||
|
||||
# Basic Build Definition
|
||||
# `.sbt` Build Definition
|
||||
|
||||
[[Previous|Getting Started Running]] _Getting Started Guide page 6 of 14._ [[Next|Getting Started Scopes]]
|
||||
|
||||
|
|
@ -8,19 +8,23 @@ This page describes sbt build definitions, including some "theory" and the
|
|||
syntax of `build.sbt`. It assumes you know how to [[use sbt|Getting Started Running]] and
|
||||
have read the previous pages in the Getting Started Guide.
|
||||
|
||||
## Basic vs. Full Definition
|
||||
## `.sbt` vs. `.scala` Definition
|
||||
|
||||
An sbt build definition can contain "basic" files, ending in `.sbt`, and
|
||||
"full" files, ending in `.scala`. You can use either one exclusively, or use
|
||||
both. A good approach is to use basic `.sbt` files for most purposes, and
|
||||
use `.scala` files only to contain what can't be done in `.sbt`:
|
||||
An sbt build definition can contain files ending in `.sbt`,
|
||||
located in the base directory, and files ending in `.scala`,
|
||||
located in the `project` subdirectory of the base directory.
|
||||
|
||||
You can use either one exclusively, or use both. A good approach
|
||||
is to use `.sbt` files for most purposes, and use `.scala` files
|
||||
only to contain what can't be done in `.sbt`:
|
||||
|
||||
- to customize sbt (add new settings or tasks)
|
||||
- to define nested sub-projects
|
||||
|
||||
This page discusses "basic" build definition, that is, `.sbt` files. See
|
||||
[[full build definition|Getting Started Full Def]] (later in Getting Started) for more on full build
|
||||
files and how they relate to basic build files.
|
||||
This page discusses `.sbt` files. See
|
||||
[[.scala build definition|Getting Started Full Def]] (later in
|
||||
Getting Started) for more on `.scala` files and how they relate to
|
||||
`.sbt` files.
|
||||
|
||||
## What is a build definition?
|
||||
|
||||
|
|
@ -115,7 +119,7 @@ The built-in keys are just fields in an object called [Keys]. A
|
|||
`sbt.Keys.name` can be referred to as `name`.
|
||||
|
||||
Custom keys may be defined in a
|
||||
[[full build definition|Getting Started Full Def]] or a [[plugin|Getting Started Using Plugins]].
|
||||
[[.scala file|Getting Started Full Def]] or a [[plugin|Getting Started Using Plugins]].
|
||||
|
||||
## Other ways to transform settings
|
||||
|
||||
|
|
@ -240,10 +244,10 @@ import Process._
|
|||
import Keys._
|
||||
```
|
||||
|
||||
(In addition, if you have a [[full build definition|Getting Started Full Def]],
|
||||
the contents of any `Build` or `Plugin` objects in that definition will be
|
||||
(In addition, if you have [[.scala files|Getting Started Full Def]],
|
||||
the contents of any `Build` or `Plugin` objects in those files will be
|
||||
imported. More on that when we get to
|
||||
[[full build definitions|Getting Started Full Def]].)
|
||||
[[.scala build definitions|Getting Started Full Def]].)
|
||||
|
||||
## Next
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ before reading this page.
|
|||
keys. Most of the keys are implemented in [Defaults].
|
||||
|
||||
Keys have one of three types. `SettingKey` and `TaskKey` are described in
|
||||
[[basic build definition|Getting Started Basic Def]]. Read about `InputKey` on the [[Input Tasks]]
|
||||
[[.sbt build definition|Getting Started Basic Def]]. Read about `InputKey` on the [[Input Tasks]]
|
||||
page.
|
||||
|
||||
Some examples from [Keys]:
|
||||
|
|
@ -35,15 +35,15 @@ The key constructors have two string parameters: the name of the key
|
|||
(`"scala-version"`) and a documentation string (`"The version of scala used for
|
||||
building."`).
|
||||
|
||||
Remember from [[basic build definition|Getting Started Basic Def]] that the type parameter `T` in `SettingKey[T]`
|
||||
Remember from [[.sbt build definition|Getting Started Basic Def]] that the type parameter `T` in `SettingKey[T]`
|
||||
indicates the type of value a setting has. `T` in `TaskKey[T]` indicates the
|
||||
type of the task's result. Also remember from [[basic build definition|Getting Started Basic Def]]
|
||||
type of the task's result. Also remember from [[.sbt build definition|Getting Started Basic Def]]
|
||||
that a setting has a fixed value until project reload, while a task is re-computed
|
||||
for every "task execution" (every time someone types a command at the sbt
|
||||
interactive prompt or in batch mode).
|
||||
|
||||
Keys may be defined in a `.scala` file (as described in
|
||||
[[full build definition|Getting Started Full Def]]), or in a plugin (as described in
|
||||
[[.scala build definition|Getting Started Full Def]]), or in a plugin (as described in
|
||||
[[using plugins|Getting Started Using Plugins]]).
|
||||
|
||||
## Implementing a task
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ Other directories in `src/` will be ignored. Additionally, all hidden directori
|
|||
You've already seen `build.sbt` in the project's base directory. Other sbt
|
||||
files appear in a `project` subdirectory.
|
||||
|
||||
`project` can contain `.scala` files, also called
|
||||
[[full build definitions|Getting Started Full Def]], when you're doing
|
||||
something too complex for a `.sbt` file.
|
||||
`project` can contain `.scala` files, which are combined with
|
||||
`.sbt` files to form the complete build definition. See
|
||||
[[.scala build definitions|Getting Started Full Def]] for more.
|
||||
|
||||
```text
|
||||
build.sbt
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# Full Build Definition
|
||||
# `.scala` Build Definition
|
||||
|
||||
[[Previous|Getting Started Library Dependencies]] _Getting Started Guide page
|
||||
10 of 14._ [[Next|Getting Started Using Plugins]]
|
||||
|
||||
This page assumes you've read previous pages in the Getting
|
||||
Started Guide, _especially_
|
||||
[[basic build definition|Getting Started Basic Def]] and
|
||||
[[.sbt build definition|Getting Started Basic Def]] and
|
||||
[[more about settings|Getting Started More About Settings]].
|
||||
|
||||
## sbt is recursive
|
||||
|
|
@ -58,7 +58,7 @@ By the way: any files ending in `.scala` or `.sbt` are used, naming them
|
|||
`build.sbt` and `Build.scala` are conventions only. This also means that
|
||||
multiple files are allowed.
|
||||
|
||||
## "full build definition" means a `.scala` file in the build definition project
|
||||
## `.scala` source files in the build definition project
|
||||
|
||||
`.sbt` files are merged into their sibling `project`
|
||||
directory. Looking back at the project layout:
|
||||
|
|
@ -82,12 +82,8 @@ The Scala expressions in `build.sbt` are compiled alongside and merged with
|
|||
_`.sbt` files in the base directory for a project become part of the
|
||||
`project` build definition project also located in that base directory._
|
||||
|
||||
`build.sbt`, also known as a
|
||||
[[basic build definition|Getting Started Basic Def]], is a convenient shorthand
|
||||
for adding settings to the build definition project.
|
||||
|
||||
A _full build definition_ is a build definition that includes `.scala` files
|
||||
underneath `project/`.
|
||||
The `.sbt` file format is a convenient shorthand for adding
|
||||
settings to the build definition project.
|
||||
|
||||
## Relating `build.sbt` to `Build.scala`
|
||||
|
||||
|
|
@ -206,9 +202,9 @@ Because the `.sbt` format allows only single expressions, it doesn't give
|
|||
you a way to share code among expressions. When you need to share code, you
|
||||
need a `.scala` file so you can set common variables or define methods.
|
||||
|
||||
You could think of it this way: there's one build definition, which is a
|
||||
nested project inside your main project. `.sbt` ("basic") and `.scala`
|
||||
("full") files are compiled together to create that single definition.
|
||||
There's one build definition, which is a nested project inside
|
||||
your main project. `.sbt` and `.scala` files are compiled
|
||||
together to create that single definition.
|
||||
|
||||
`.scala` files are also required to define multiple projects in a single
|
||||
build. More on that is coming up in
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ try out live Scala examples based on your project's code.
|
|||
|
||||
## Build definition
|
||||
|
||||
Most projects will need some manual setup. Basic build definitions are done
|
||||
in a file called `build.sbt` placed in the project's base directory.
|
||||
Most projects will need some manual setup. Basic build settings go
|
||||
in a file called `build.sbt`, located in the project's base directory.
|
||||
|
||||
For example, if your project is in the directory `hello`, in `hello/build.sbt` you might write:
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ version := "1.0"
|
|||
scalaVersion := "2.9.1"
|
||||
```
|
||||
|
||||
In [[basic build definition|Getting Started Basic Def]] you'll learn more about how to write a `build.sbt` file.
|
||||
In [[.sbt build definition|Getting Started Basic Def]] you'll learn more about how to write a `build.sbt` file.
|
||||
|
||||
If you plan to package your project in a jar, you will want to set at least
|
||||
the name and version in a `build.sbt`.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
9 of 14._ [[Next|Getting Started Full Def]]
|
||||
|
||||
This page assumes you've read the earlier Getting Started pages, in particular
|
||||
[[basic build definition|Getting Started Basic Def]],
|
||||
[[.sbt build definition|Getting Started Basic Def]],
|
||||
[[scopes|Getting Started Scopes]], and [[more about settings|Getting Started More About Settings]].
|
||||
|
||||
Library dependencies can be added in two ways:
|
||||
|
|
@ -230,4 +230,4 @@ dependencies [[on this page|Library-Management]], if you didn't find an
|
|||
answer on this introductory page.
|
||||
|
||||
If you're reading Getting Started in order, for now, you might move on to
|
||||
read [[full build definition|Getting Started Full Def]].
|
||||
read [[.scala build definition|Getting Started Full Def]].
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
This page explains other ways to create a `Setting`, beyond the basic `:=`
|
||||
method. It assumes you've read [[basic build definition|Getting Started Basic Def]] and [[scopes|Getting Started Scopes]].
|
||||
method. It assumes you've read [[.sbt build definition|Getting Started Basic Def]] and [[scopes|Getting Started Scopes]].
|
||||
|
||||
## Refresher: Settings
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ transformed map. For example, if you transform a map with the setting
|
|||
|
||||
Settings must end up in the master list of settings to do any good (all
|
||||
lines in a `build.sbt` automatically end up in the list, but in a
|
||||
[[full build definition|Getting Started Full Def]] you can get it wrong).
|
||||
[[.scala file|Getting Started Full Def]] you can get it wrong).
|
||||
|
||||
## Appending to previous values: `+=` and `++=`
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ This page introduces multiple projects in a single build.
|
|||
Please read the earlier pages in the Getting Started Guide first,
|
||||
in particular you need to understand
|
||||
[[build.sbt|Getting Started Basic Def]] and
|
||||
[[full build definition|Getting Started Full Def]] before reading
|
||||
[[.scala build definition|Getting Started Full Def]] before reading
|
||||
this page.
|
||||
|
||||
## Multiple projects
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism
|
|||
7 of 14._ [[Next|Getting Started More About Settings]]
|
||||
|
||||
This page describes scopes. It assumes you've read and understood the
|
||||
previous page, [[basic build definition|Getting Started Basic Def]].
|
||||
previous page, [[.sbt build definition|Getting Started Basic Def]].
|
||||
|
||||
## The whole story about keys
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ $ sbt
|
|||
```
|
||||
|
||||
On the first line, you can see this is a task (as opposed to a setting, as
|
||||
explained in [[basic build definition|Getting Started Basic Def]]). The value resulting from the task
|
||||
explained in [[.sbt build definition|Getting Started Basic Def]]). The value resulting from the task
|
||||
will have type `scala.collection.Seq[sbt.Attributed[java.io.File]]`.
|
||||
|
||||
"Provided by" points you to the scoped key that defines the value, in this
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ To create an sbt project, you'll need to take these steps:
|
|||
- Create a project directory with source files in it.
|
||||
- Create your build definition.
|
||||
- Move on to [[running|Getting Started Running]] to learn how to run sbt.
|
||||
- Then move on to [[basic build definition|Getting Started Basic Def]] to learn more about build definitions.
|
||||
- Then move on to [[.sbt build definition|Getting Started Basic Def]] to learn more about build definitions.
|
||||
|
||||
# Installing sbt
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ to know.
|
|||
- the basics of Scala. It's undeniably helpful to be familiar with Scala
|
||||
syntax. [Programming in Scala](http://www.artima.com/shop/programming_in_scala_2ed)
|
||||
written by the creator of Scala is a great introduction.
|
||||
- [[Basic build definition|Getting Started Basic Def]]
|
||||
- [[.sbt build definition|Getting Started Basic Def]]
|
||||
- your build definition is one big list of `Setting` objects, where a
|
||||
`Setting` transforms the set of key-value pairs sbt uses to perform tasks.
|
||||
- to create a `Setting`, call one of a few methods on a key (the `:=` and
|
||||
|
|
@ -39,9 +39,9 @@ to know.
|
|||
per-task, or per-configuration.
|
||||
- the per-project axis also supports "entire build" scope.
|
||||
- scopes "fall back to" or delegate to more general scopes.
|
||||
- Basic vs. [[Full|Getting Started Full Def]]
|
||||
- put most of your settings in basic (`build.sbt`), but use the full
|
||||
build definition to
|
||||
- `.sbt` vs. [[.scala|Getting Started Full Def]] build definition
|
||||
- put most of your settings in `build.sbt`, but use `.scala`
|
||||
build definition files to
|
||||
[[define multiple subprojects|Getting Started Multi-Project]], and to factor out
|
||||
common values, objects, and methods.
|
||||
- the build definition is an sbt project in its own right,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Please read the earlier pages in the Getting Started Guide first,
|
|||
in particular you need to understand
|
||||
[[build.sbt|Getting Started Basic Def]],
|
||||
[[library dependencies|Getting Started Library Dependencies]], and
|
||||
[[full build definition|Getting Started Full Def]] before reading
|
||||
[[.scala build definition|Getting Started Full Def]] before reading
|
||||
this page.
|
||||
|
||||
## What is a plugin?
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ It is _highly recommended_ to read the Getting Started Guide!
|
|||
|
||||
If you are in a huge hurry, the most important conceptual
|
||||
background can be found in
|
||||
[[basic build definition|Getting Started Basic Def]],
|
||||
[[.sbt build definition|Getting Started Basic Def]],
|
||||
[[scopes|Getting Started Scopes]], and
|
||||
[[more about settings|Getting Started More About Settings]]. But
|
||||
we don't promise that it's a good idea to skip the other pages in
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
* [[Hello, World|Getting Started Hello]] - Create a simple project
|
||||
* [[Directory Layout|Getting Started Directories]] - Basic project layout
|
||||
* [[Running|Getting Started Running]] - The command line and interactive mode
|
||||
* [[Basic Build Definition|Getting Started Basic Def]] - Understanding build.sbt settings
|
||||
* [[.sbt Build Definition|Getting Started Basic Def]] - Understanding build.sbt settings
|
||||
* [[Scopes|Getting Started Scopes]] - Put settings in context
|
||||
* [[More About Settings|Getting Started More About Settings]] - Settings based on other settings
|
||||
* [[Library Dependencies|Getting Started Library Dependencies]] - Adding jars or managed dependencies
|
||||
* [[Full Build Definition|Getting Started Full Def]] - When build.sbt is not enough
|
||||
* [[.scala Build Definition|Getting Started Full Def]] - When build.sbt is not enough
|
||||
* [[Using Plugins|Getting Started Using Plugins]] - Adding plugins to the build
|
||||
* [[Multi-Project Builds|Getting Started Multi-Project]] - Adding sub-projects to the build
|
||||
* [[Custom Settings and Tasks|Getting Started Custom Settings]] - Intro to extending sbt
|
||||
|
|
|
|||
4
Home.md
4
Home.md
|
|
@ -2,8 +2,8 @@ sbt is a build tool for Scala and Java projects that aims to do the basics well.
|
|||
|
||||
## Features
|
||||
* Easy to set up for simple projects
|
||||
* [[Basic build definition|Getting Started Basic Def]] uses a Scala-based "domain-specific language" (DSL)
|
||||
* More advanced [[full build definitions|Getting Started Full Def]] and [[extensions|Getting Started Custom Settings]] use the full flexibility of unrestricted Scala code
|
||||
* [[.sbt build definition|Getting Started Basic Def]] uses a Scala-based "domain-specific language" (DSL)
|
||||
* More advanced [[.scala build definitions|Getting Started Full Def]] and [[extensions|Getting Started Custom Settings]] use the full flexibility of unrestricted Scala code
|
||||
* Accurate incremental recompilation using information extracted from the compiler
|
||||
* Continuous compilation and testing with [[triggered execution|Triggered Execution]]
|
||||
* Packages and publishes jars
|
||||
|
|
|
|||
Loading…
Reference in New Issue