sbt

Wanted: Scala Cookbook reviewers

UPDATE: I originally posted this article in January, 2013, and it's now mid-February, 2013, and we're no longer looking for reviewers. I've only kept this page here so people won't get 404 errors.

OLD CONTENT:

Interested in being a reviewer for the Scala Cookbook?

How to set the Scala version in the SBT build.sbt configuration file

SBT FAQ: How do I set the desired Scala compiler version in the SBT build.sbt configuration file?

Set the value of the scalaVersion variable in your SBT build.sbt file. For instance, to use Scala 2.9.2, put an entry like this in the build.sbt file:

scalaVersion := "2.9.2"

To use Scala 2.10.0, put an entry like this in the build.sbt file:

How to put SBT into offline mode with a command line setting

Scala SBT FAQ: How do I put SBT into "offline mode" so I can use it while working on an airplane, or any other location where I don't have a WiFi connection?

Use this setting at the SBT command prompt:

> set offline := true

Warning: I honestly don't know how well this works. I have tried it a few times, and I know it prints out a ton of output, but I haven't paid attention to all that output to see exactly what it does.

To reverse the setting, just change it to false instead of true:

A shell script to build a Scala SBT project directory structure

Just a quick note here that I'm developing a simple shell script to build a Scala SBT project directory structure. Here's the shell script in its current incarnation:

Scala SBT and build.sbt syntax and examples

Note: This page is very much a work in progress.

A sample Scala SBT build.sbt file, including the last line, which handles the SBT 're-run with -deprecation for details' warning message. (If you get the 're-run with -deprecation' message, that last line hands the "-deprecation" option over to the compiler, so you can see the deprecation problems.)

Using GitHub projects as Scala library dependencies with sbt and sbteclipse

Okay, this is pretty cool. With sbt, you can magically refer to dependencies that are set up as GitHub projects, and those projects don't need to have a jar file, they can just be a source code library. This means you can save your Scala libraries as source code to GitHub (like you normally would), then pull them into your other Scala projects simply by referencing them in your build.sbt file.

Assuming you're comfortable with sbt, here's a quick six-step example that shows how to pull a GitHub library into a simple Scala project:

Scala SBT tool history commands

When you're using the SBT tool with your Scala projects, it can be helpful to list your "sbt history", the history of your SBT commands. Courtesy of the SBT tool itself, here are the history commands you can use from the sbt command line:

Scala SBT documentation in PDF format

I did some manual labor this weekend, and converted the Scala SBT tool documentation into PDF format (a PDF file). I also tried to contact the SBT author, Mark Harrah, to see if he wanted the PDF on the Github website, but I couldn't find any way to email him through Github, so ...

If you want a copy of the Scala SBT documentation in PDF format, current as of June 3, 2012, here it is:

A Scala Spring Framework dependency injection example

Curious about how well Scala would play with the Spring Framework, I created a small Scala/Spring dependency injection example project, which I'm sharing here.

The short answer is that Scala worked just fine with Spring, but it also showed me that I still have plenty to learn about inheritance in Scala.

My Spring applicationContext.xml file

I copied a Spring applicationContext.xml file from another project, then whittled it down to these bare essentials:

Syndicate content