My favorites | Sign in
Project Logo
                
Search
for
Updated Nov 03, 2009 by dmharrah
LocalScala  

There are two ways to use sbt with Scala 2.8 (the trunk version of Scala). Both ways involve building sbt locally. The first way is easier and can be used if you want to work with nightly snapshots. The second way is required if you want to use a custom build of Scala.

Scala Nightly Build

Setup

  1. Get the sbt loader set up on your system according to the Launching Sbt section. You need the 0.5.5 launcher (or newer) to use a specific nightly snapshot.
  2. Checkout sbt
  3.  $ svn checkout http://simple-build-tool.googlecode.com/svn/trunk/ sbt
  4. Select the nightly snapshot you want from Scala Tools Snapshots. The files there look like:
  5.   scala-compiler-2.8.0-20090910.003346-219.jar
Take the version and replace the last number (the build number) with a '+'. For example:
  2.8.0-20090910.003346-+
This is the version to specify below. (The '+' is like a wildcard at the end of the version in Ivy. It is required because the build numbers for scala-library and scala-compiler do not match. You will notice that Ivy is slower to resolve when using '+'.)
  1. Edit $SBT_HOME/project/build/CrossCompileProject.scala:
    1. Change the 2.8 version string to the Scala version determined above (around line 16)
    2.   private val version2_8_0 = "2.8.0-20090910.003346-+"
    3. Optional: to save time by building only the latest versions, make this change to line 31:
    4.   private val buildConfigurations = conf_2_7_5 :: conf_2_8_0 :: Nil
  2. Build sbt by running sbt in the checked out directory, do:
  3.  $ sbt
     > update
     > full-build
  4. Use this local version of sbt in your project by setting your sbt.version to 0.5.7-SNAPSHOT and your scala.version to the version above (for example: 2.8.0-20090910.003346-+).
  5. You will need to use the version of the launcher in target/.

Custom Scala Build

Setup

  1. Get the sbt loader set up on your system according to the Launching Sbt section.
  2. Checkout sbt
  3.  svn checkout http://simple-build-tool.googlecode.com/svn/trunk/ sbt
  4. Edit $SBT_HOME/project/build/CrossCompileProject.scala:
    1. Change the 2.8 version string to identify the local Scala version (around line 16)
    2.   private val version2_8_0 = "2.8.0-local"
    3. Optional: to save time by building only the latest versions, make this change to line 31:
    4.   private val buildConfigurations = conf_2_7_5 :: conf_2_8_0 :: Nil
  5. For the Scala build you want to use, put the project definition below in:
  6.  $SCALA_HOME/project/build/ScalaJars.scala
$SCALA_HOME/project/build/build.properties should contain:
 project.name=scala
 project.organization=org.scala-lang
 project.version=2.8.0-local.
  1. This is just a quick definition to locally publish the already built jars build/pack/lib/scala-compiler.jar and build/pack/lib/scala-library.jar. In $SCALA_HOME, do:
  2.  $ sbt publish-local
  3. Then, run the following in $SBT_HOME
  4.  $ sbt
     > update
     > cross-publish-local
  5. Run sbt in your project directory. You will be prompted for name, organization and version. Enter 2.8.0-local for Scala and 0.5.7-SNAPSHOT for sbt. You should be all set now. When you want to update the compiler follow the steps in the next section.

New compiler

For a new compiler:

  1. In $SCALA_HOME, after building the new Scala version,
  2.    $ sbt publish-local
  3. In $SBT_HOME
  4.    $ sbt
       > clean-lib
       > update
       > cross-publish-local
  5. Remove the project/boot directory from your project (sbt is not designed to update Scala jars after they have been copied to a project, so you have to manually delete them. If using a local Scala version is popular, maybe this could change.)
  6. Then, run sbt on your project as normal.

Project Definition

import sbt._

class ScalaJars(info: ProjectInfo) extends ParentProject(info)
{ top =>
  override def outputPath: Path = "build"
  val library = project(".", "Scala Library", new SubProject(_))
  val compiler = project(".", "Scala Compiler", new SubProject(_), library)

  override def shouldCheckOutputDirectories = false

  class SubProject(info: ProjectInfo) extends DefaultProject(info)
  {
    override def outputPath = top.outputPath / "pack" / "lib"
    override def shouldCheckOutputDirectories = false
    override def publishLocalConfiguration = new DefaultPublishConfiguration("local", "release", true) {
      override def srcArtifactPatterns: Iterable[String] = List(outputPath / "[artifact].[ext]").map(_.relativePath)
    }
  }
}

Comment by sethtisue, Aug 28, 2009

$SBT_HOME/project/build/src/CrossCompileProject?.scala should be just $SBT_HOME/project/build/CrossCompileProject?.scala

Comment by dmharrah, Aug 28, 2009

Thanks! -Mark

Comment by jzaugg, Oct 04, 2009

I'm trying the first method, but it looks like the wrong pattern is being used to search the snapshot repository. How can I configure the correct pattern: http://scala-tools.org/repo-snapshots/[organization]/[module]/2.8.0-SNAPSHOT/[artifact]-[revision].[ext]

[warn]   [SNAPSHOT]
[warn]   -- artifact org.scala-lang#scala-compiler;20091004.003722-+!scala-compiler.jar:
[warn]   http://scala-tools.org/repo-snapshots/org/scala-lang/scala-compiler/[revision]/scala-compiler-[revision].jar

...

[info] == Simple Build Tool / update ==
[error] Error running update: unresolved dependency: org.scala-lang#scala-compiler;20091004.003722-+: not found
[error] unresolved dependency: org.scala-lang#scala-library;20091004.003722-+: not found
[info] 
Comment by dmharrah, Oct 04, 2009

Make sure you using the 0.5.5 launcher. The ability to specify a specific snapshot was introduced in that version of the launcher. I've updated the page to mention that.

-Mark

Comment by rickynils, Oct 13, 2009

When I try to do publish-local on a project built with a nightly Scala according to the first method above, sbt complains (in make-pom) that it can't find the scala-library:

error? Error running deliver-local: unresolved dependency: org.scala-lang#scala-library;2.8.0-20091013.004057-+: not found

Comment by felipero, Dec 16, 2009

if you use 2.8.0-SNAPSHOT it will work perfectly. No need to find the specific scala version.

Comment by dmharrah, Dec 16, 2009

Sure, until the underlying version you built sbt with is incompatible with the latest nightly. In any case, I think most people on 2.8 are using 0.6.x now, even though it is experimental.

-Mark


Sign in to add a comment
Hosted by Google Code