|
LocalScala
sbt has movedsbt has now completely moved to GitHub. See https://github.com/harrah/xsbt/wiki/Local-Scala. sbt 0.7 makes using a locally built version of Scala easier than previous versions. sbt just needs to know where the library and compiler jars are for this version. A ScalaInstance object represents a version of Scala, backed by compiler and library jar locations. To get a ScalaInstance for a local Scala, call one of the variants of defineScala: /** Get a `ScalaInstance` for the Scala version with base directory `home`. The library and compiler jars are * assumed to be at `new File(home, "lib/scala-library.jar")` and `new File(home, "lib/scala-compiler.jar")`. * The label for this instance is determined by the version String in the `compiler.properties` file in `scala-compiler.jar`.*/ def defineScala(home: File): ScalaInstance /** Get a `ScalaInstance` for the Scala version with base directory `home`. The library and compiler jars are * assumed to be at `new File(home, "lib/scala-library.jar")` and `new File(home, "lib/scala-compiler.jar")`. * `version` is used as the label for this instance.*/ def defineScala(version: String, home: File): ScalaInstance The label referred to in the comments is how you refer to this version in your build.scala.versions property and in the ++<version> version switching command. Override the localScala method to declare these local instances to sbt: override def localScala =
defineScala("2.8.0-local", new File(scalaRoot + "/build/pack/")) ::
NilInclude it in build.scala.versions: $ cat project/build.properties ... build.scala.versions=2.8.0.RC2 2.8.0-local 2.7.7 ... or use it temporarily with ++<version>: $ sbt "++2.8.0-local compile" "++2.7.7 compile" sbt reuses the class loader for the local Scala version. If you recompile your local Scala version and you are using sbt interactively, run > reload to use the new compilation results. | |
$SBT_HOME/project/build/src/CrossCompileProject?.scala should be just $SBT_HOME/project/build/CrossCompileProject?.scala
Thanks! -Mark
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]
...
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
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
if you use 2.8.0-SNAPSHOT it will work perfectly. No need to find the specific scala version.
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
I tried to follow these instructions using sbt-launch-0.7.0.jar. The project file can not be compiled because the ScalaInstance? type is not found. I have added the "import sbt." statement.
Sorry about that. ScalaInstance? is still under the xsbt namespace. You don't actually need to reference it. I've fixed the example.
Note that Scala trunk is currently undergoing classpath changes that mean sbt can't work with it.
-Mark
Hi Mark,
will you inform the sbt users when Scala trunk can be used as a local version again? They recently fixed an important issue for me and I would like to benefit from the fix in my sbt project.
Thanks, --Stefan
Yes.
Hi,
sbt 0.7.4 seems to come pre-packaged retrieve and build on Scala 2.8.0RC2 -- will there be a release to support the (new) Scala 2.8.0-final ?
Thanks -- Dave
I am trying to use a local scala that is defined outside of the project directory, so I have
defineScala("2.8.x-virtualized-SNAPSHOT", new File("../scala-virtualized/build/pack"))::Nil
I can run the compile action fine, but if I try to do test-compile it fails:
I tried with another project and publish-local also fails if the localScala is outside the directory.
I also tried absolute paths, like this:
defineScala("2.8.x-virtualized-SNAPSHOT", new File("/Code/scala-virtualized/build/pack"))::Nil
and that does not help either.
This is on Windows.
Looks like I was able to get this to work, with the drive specified.
defineScala("2.8.x-virtualized-SNAPSHOT", new File("C:/Code/scala-virtualized/build/pack"))::Nil