Skip to content
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

Merged
merged 25 commits into from
Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/nanoc/content/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ There's also the [Gitter sbt/sbt][gitter1] channel, but the options above are re
<h2 id="how-can-I-help">How can I help? <a href="#how-can-I-help" class="header-link"><span class="header-link-content">&nbsp;</span></a></h2>

sbt is an open source project and everyone is encouraged to get involved!
Join the community of developers building sbt and related tools like Play and Activator.
Join the community of developers building sbt and related tools like Play.

### Twitter

Expand Down
8 changes: 1 addition & 7 deletions src/nanoc/content/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,9 @@ <h2>Gentoo</h2>
</div>
</div>

<div clsas="arg_all">
<div class="arc_all">
<h2>All platforms</h2>
<a href="https://dl.bintray.com/sbt/native-packages/sbt/<%= @config[:sbtVersion] %>/sbt-<%= @config[:sbtVersion] %>.zip" class="btn" role="button">sbt-<%= @config[:sbtVersion] %>.zip</a>

<a href="https://dl.bintray.com/sbt/native-packages/sbt/<%= @config[:sbtVersion] %>/sbt-<%= @config[:sbtVersion] %>.tgz" class="btn" role="button">sbt-<%= @config[:sbtVersion] %>.tgz</a>
</div>

<div class="arc_all">
<h2>Manual installation</h2>

See <a href="<%= @config[:sbtBinaryVersion] %>/docs/Manual-Installation.html">instruction for manual installation</a>.
</div>
6 changes: 3 additions & 3 deletions src/reference/00-Getting-Started/00.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ out: Getting-Started.html

[Basic-Def]: Basic-Def.html
[Scopes]: Scopes.html
[More-About-Settings]: More-About-Settings.html
[Task-Graph]: Task-Graph.html

Getting Started with sbt
========================
Expand All @@ -20,8 +20,8 @@ and maintain an sbt build definition.
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 [.sbt build definition][Basic-Def], [scopes][Scopes], and
[more kinds of setting][More-About-Settings]. But we don't promise that
be found in [build definition][Basic-Def], [scopes][Scopes], and
[task graph][Task-Graph]. But we don't promise that
it's a good idea to skip the other pages in the guide.

It's best to read in order, as later pages in the Getting Started Guide
Expand Down
8 changes: 3 additions & 5 deletions src/reference/00-Getting-Started/01-Setup/00.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ out: Setup.html
[Mac]: Installing-sbt-on-Mac.html
[Windows]: Installing-sbt-on-Windows.html
[Linux]: Installing-sbt-on-Linux.html
[Manual-Installation]: Manual-Installation.html

Installing sbt
--------------

To create an sbt project, you'll need to take these steps:

- Install sbt and create a script to launch it.
- Install sbt.
- Setup a simple [hello world][Hello] project
- Create a project directory with source files in it.
- Create your build definition.
Expand All @@ -28,9 +27,8 @@ To create an sbt project, you'll need to take these steps:
Ultimately, the installation of sbt boils down to a launcher JAR
and a shell script, but depending on your platform, we provide
several ways to make the process less tedious. Head over to the
installation steps for [Mac][Mac], [Windows][Windows],
[Linux][Linux], or
[manual installation][Manual-Installation].
installation steps for [Mac][Mac], [Windows][Windows], or
[Linux][Linux].
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU/Linux

Copy link

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.


### Tips and Notes

Expand Down
20 changes: 8 additions & 12 deletions src/reference/00-Getting-Started/01-Setup/a.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link

@milessabin milessabin Jan 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the vanilla launcher supports .jvmopts I've stopped using sbt-extras.

Choose a reason for hiding this comment

The 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.

8 changes: 2 additions & 6 deletions src/reference/00-Getting-Started/01-Setup/b.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ out: Installing-sbt-on-Windows.html
Installing sbt on Windows
-------------------------

### Windows installer

Download [msi installer][MSI] and install it.

### Installing from a universal package

Download [ZIP][ZIP] or [TGZ][TGZ] package and expand it.

### Installing manually
### Windows installer

See instruction to install manually.
Download [msi installer][MSI] and install it.
4 changes: 0 additions & 4 deletions src/reference/00-Getting-Started/01-Setup/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,3 @@ To merge sbt from this ebuilds you can do:

> **Note:** Please report any issues with the ebuild
> [here](https://github.com/whiter4bbit/overlays/issues).

### Installing manually

See [instructions to install manually][Manual-Installation].
97 changes: 0 additions & 97 deletions src/reference/00-Getting-Started/01-Setup/d.md

This file was deleted.

12 changes: 0 additions & 12 deletions src/reference/00-Getting-Started/01-Setup/e.md

This file was deleted.

89 changes: 31 additions & 58 deletions src/reference/00-Getting-Started/02-Hello.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

@tpolecat tpolecat Dec 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to simply say

This page assumes you've installed sbt 0.13.10 or later.

Since there are is no guidance given for creating a project by hand? This seems fine, although sbt new does not work for me and I have a hard time believing I'm the only person with this problem. We'll find out I guess. Edit: resolved

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
Loading