~ sbt downloads itself the nightly build of the scala compiler webacl
authorAlexandre Bertails <bertails@w3.org>
Mon, 21 Nov 2011 11:38:59 -0500
branchwebacl
changeset 131 8c38062c7809
parent 130 aa09c5e9d204
child 134 4f7578d03d3c
~ sbt downloads itself the nightly build of the scala compiler
.hgignore
project/build.scala
--- a/.hgignore	Sun Nov 20 19:25:34 2011 -0500
+++ b/.hgignore	Mon Nov 21 11:38:59 2011 -0500
@@ -20,3 +20,4 @@
 .settings
 .idea
 .idea_modules
+bin
\ No newline at end of file
--- a/project/build.scala	Sun Nov 20 19:25:34 2011 -0500
+++ b/project/build.scala	Mon Nov 21 11:38:59 2011 -0500
@@ -39,6 +39,8 @@
 // general build settings
 object BuildSettings {
 
+  val logger = ConsoleLogger()
+
   val buildOrganization = "org.w3"
   val buildVersion      = "0.1-SNAPSHOT"
   val buildScalaVersion = "2.9.1"
@@ -46,8 +48,26 @@
   val buildSettings = Defaults.defaultSettings ++ Seq (
     organization := buildOrganization,
     version      := buildVersion,
-    scalaVersion := buildScalaVersion,
-    scalaHome    := Some(file("/home/betehess/tools/scala")),
+    scalaVersion := buildScalaVersion, // ignored b/c of scalaHome
+    scalaHome    := Some {
+      val bin = file("bin")
+//      import scala.collection.JavaConverters._
+      def latest = (bin.listFiles.toList filter { _.getName startsWith "scala-2.10.0.r" } sortWith { _.getName > _.getName }).headOption
+      latest match {
+        case Some(scala) => {
+          logger.info("found nightly build of scala compiler: %s" format scala.getName)
+          scala
+        }
+        case None => {
+          logger.info("downloading the latest scala compiler (nightly builds)")
+          val u = url("http://www.scala-lang.org/archives/downloads/distrib/files/nightly/distributions/scala-2.10.0.latest.zip")
+          val zip = file("/tmp/scala-latest.zip")
+          u #> zip !;
+          Process("unzip -o %s -d %s" format (zip.getAbsolutePath, bin.getAbsolutePath)) !;
+          latest getOrElse sys.error("couldn't download and set the latest scala compiler") 
+        }
+      }
+    },
     parallelExecution in Test := false,
     scalacOptions ++= Seq("-deprecation", "-unchecked")
   )