-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update sbt Getting Started guide #306
Changes from all commits
e51588b
fc8531e
db41b59
d9c6705
f16cba9
e07ca32
3b99844
06cddab
ec45c8c
6074bfe
2dcc0ae
a55fc0d
b0ce43d
4c358f0
2196696
8557a03
94cbae7
1ad943e
b4ce1d5
f4236f0
7714476
8f6a204
45aaa78
3f3a253
e7f479f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,28 +9,24 @@ out: Installing-sbt-on-Mac.html | |
Installing sbt on Mac | ||
--------------------- | ||
|
||
### Installing from a universal package | ||
|
||
Download [ZIP][ZIP] or [TGZ][TGZ] package, and expand it. | ||
|
||
### Installing from a third-party package | ||
|
||
> **Note:** Third-party packages may not provide the latest version. Please make | ||
> sure to report any issues with these packages to the relevant | ||
> maintainers. | ||
|
||
#### [Macports](http://macports.org/) | ||
|
||
``` | ||
\$ port install sbt | ||
``` | ||
|
||
#### [Homebrew](http://mxcl.github.com/homebrew/) | ||
|
||
``` | ||
\$ brew install sbt | ||
``` | ||
|
||
### Installing from a universal package | ||
|
||
Download [ZIP][ZIP] or [TGZ][TGZ] package, and expand it. | ||
|
||
### Installing manually | ||
#### [Macports](http://macports.org/) | ||
|
||
See instruction to install manually. | ||
``` | ||
\$ port install sbt | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think pretty much everyone I know uses sbt-extras … it would be nice to at least mention it or even recommend it directly. Personally I think it should be the one and only launcher, although it may not work on Windows. dunno. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of October it does work on Windows (Cygwin): dwijnand/sbt-extras#167 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. The launcher story is a mess on its own so I've split it up to sbt/sbt#2889 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that the vanilla launcher supports There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @milessabin In my experience, sbt-extras is considerably more reliable at dealing with a number of cases than the vanilla launcher, including sbt version. I've also seen occasional really bizarre dependency symptoms in someone else's build that were fixed by swapping from the vanilla launcher to sbt-extras. It's still the standard, in my book. |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,87 +4,60 @@ out: Hello.html | |
|
||
[Basic-Def]: Basic-Def.html | ||
[Setup]: Setup.html | ||
[Running]: Running.html | ||
|
||
Hello, World | ||
------------ | ||
|
||
This page assumes you've [installed sbt][Setup]. | ||
This page assumes you've [installed sbt][Setup] 0.13.13 or later. | ||
|
||
### Create a project directory with source code | ||
### sbt new command | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to simply say
Since there are is no guidance given for creating a project by hand? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to put the disclaimer. There's also a project that we're working on that turns select Giter8 template into a download, so we can try that too. |
||
|
||
A valid sbt project can be a directory containing a single source file. | ||
Try creating a directory `hello` with a file `hw.scala`, containing the | ||
following: | ||
If you're using sbt 0.13.13 or later, you can use sbt `new` command to quickly setup a simple Hello world build. Type the following command to the terminal. | ||
|
||
```scala | ||
object Hi { | ||
def main(args: Array[String]) = println("Hi!") | ||
} | ||
``` | ||
\$ sbt new sbt/scala-seed.g8 | ||
.... | ||
Minimum Scala build. | ||
|
||
Now from inside the `hello` directory, start sbt and type `run` at the sbt | ||
interactive console. On Linux or OS X the commands might look like this: | ||
name [My Something Project]: hello | ||
|
||
Template applied in ./hello | ||
``` | ||
|
||
When prompted for the project name, type `hello`. | ||
|
||
This will create a new project under a directory named `hello`. | ||
|
||
### Running your app | ||
|
||
Now from inside the `hello` directory, start `sbt` and type `run` at the sbt shell. On Linux or OS X the commands might look like this: | ||
|
||
``` | ||
\$ mkdir hello | ||
\$ cd hello | ||
\$ echo 'object Hi { def main(args: Array[String]) = println("Hi!") }' > hw.scala | ||
\$ sbt | ||
... | ||
> run | ||
... | ||
Hi! | ||
[info] Compiling 1 Scala source to /xxx/hello/target/scala-2.12/classes... | ||
[info] Running example.Hello | ||
hello | ||
``` | ||
|
||
In this case, sbt works purely by convention. sbt will find the | ||
following automatically: | ||
We will see more tasks [later][Running]. | ||
|
||
- Sources in the base directory | ||
- Sources in `src/main/scala` or `src/main/java` | ||
- Tests in `src/test/scala` or `src/test/java` | ||
- Data files in `src/main/resources` or `src/test/resources` | ||
- jars in `lib` | ||
### Exiting sbt shell | ||
|
||
By default, sbt will build projects with the same version of Scala used | ||
to run sbt itself. | ||
To leave sbt shell, type `exit` or use Ctrl+D (Unix) or Ctrl+Z | ||
(Windows). | ||
|
||
You can run the project with `sbt run` or enter the [Scala | ||
REPL](http://www.scala-lang.org/node/2097) with `sbt console`. Invoking `sbt console` | ||
sets up your project's classpath so you can try out live Scala examples | ||
based on your project's code. | ||
``` | ||
> exit | ||
``` | ||
|
||
### Build definition | ||
|
||
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: | ||
|
||
```scala | ||
lazy val root = (project in file(".")). | ||
settings( | ||
name := "hello", | ||
version := "1.0", | ||
scalaVersion := "$example_scala_version$" | ||
) | ||
``` | ||
|
||
The build definition goes in a file called `build.sbt`, located in the project's base directory. | ||
You can take a look at the file, but don't worry if the details of this build file aren't clear yet. | ||
In [.sbt build definition][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`. | ||
|
||
### Setting the sbt version | ||
|
||
You can force a particular version of sbt by creating a file | ||
`hello/project/build.properties`. In this file, write: | ||
|
||
``` | ||
sbt.version=$app_version$ | ||
``` | ||
|
||
to force the use of sbt $app_version$. sbt is 99% source compatible from | ||
release to release. Still, setting the sbt version in | ||
`project/build.properties` avoids any potential confusion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GNU/Linux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, don't upset Stallman.