Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make sbt use the scala binaries from $SCALA_HOME directory?

Tags:

scala

sbt

sbt downloads new version of scala compiler and the scala library for every sbt project at this location: ./project/boot/scala-2.8.1/lib/scala-library.jar
./project/boot/scala-2.8.1/lib/scala-compiler.jar

How do I make it pick up the compiler and the library from the location pointed by $SCALA_HOME?

Also, I am surprised that it's not a common requirement. Do Scala developers prefer to use a separate copies of compiler and library for every project?

I found the same request which was unanswered: http://groups.google.com/group/simple-build-tool/browse_thread/thread/9e2c7bc34253ad0f?pli=1

Thanks in advance for your help.

like image 202
Salil Avatar asked Apr 05 '11 22:04

Salil


People also ask

Where does sbt download Scala?

Having said that, at the very beginning, sbt will always download its own internal dependencies, Scala including. It is then saved in ~/. sbt/boot . p.s. The versions of Scala used by sbt internally are not at all different from the ones you may have downloaded already for your Scala/sbt projects.

Which version of Scala does sbt use?

sbt uses that same version of Scala to compile the build definitions that you write for your project because they use sbt APIs. This version of Scala is fixed for a specific sbt release and cannot be changed. For sbt 1.7. 1, this version is Scala 2.12.

Does sbt install Scala?

sbt will download Scala for you. If you install sbt-extras (basically just a script) you don't even need to download sbt : it will automatically download the sbt launcher you need. Very handy since you just need to specify sbt. version in your build.


1 Answers

Disclaimer, I don't use this myself but I was curious about whether this is possible.

Based on using a local scala instance, I defined the following project:

import sbt._
import java.io.File

class Test(info: ProjectInfo) extends DefaultProject(info) {
  override def localScala = 
    defineScala("2.8.1-local", new File(System.getenv("SCALA_HOME"))) :: Nil
}

Then in project/build/build.properties:

build.scala.versions=2.8.1-local

Then I can see that the console target works fine, which would suggest that it would work for compilation and running as well.

like image 65
huynhjl Avatar answered Nov 04 '22 10:11

huynhjl