From f52726c2212d71e8ca3ddcca2f5829ca752520d5 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 26 Jul 2011 10:57:20 -0400 Subject: [PATCH] add ability to specify actual version for ScalaInstance. ref #127. --- util/classpath/ScalaInstance.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/util/classpath/ScalaInstance.scala b/util/classpath/ScalaInstance.scala index 987c03a96..a112ebcd2 100644 --- a/util/classpath/ScalaInstance.scala +++ b/util/classpath/ScalaInstance.scala @@ -10,12 +10,12 @@ package sbt * for the compiler itself. * The 'version' field is the version used to obtain the Scala classes. This is typically the version for the maven repository. * The 'actualVersion' field should be used to uniquely identify the compiler. It is obtained from the compiler.properties file.*/ -final class ScalaInstance(val version: String, val loader: ClassLoader, val libraryJar: File, val compilerJar: File, val extraJars: Seq[File]) extends NotNull +final class ScalaInstance(val version: String, val loader: ClassLoader, val libraryJar: File, val compilerJar: File, val extraJars: Seq[File], val explicitActual: Option[String]) { require(version.indexOf(' ') < 0, "Version cannot contain spaces (was '" + version + "')") def jars = libraryJar :: compilerJar :: extraJars.toList /** Gets the version of Scala in the compiler.properties file from the loader. This version may be different than that given by 'version'*/ - lazy val actualVersion = ScalaInstance.actualVersion(loader)("\n version " + version + ", " + jarStrings) + lazy val actualVersion = explicitActual getOrElse ScalaInstance.actualVersion(loader)("\n version " + version + ", " + jarStrings) def jarStrings = "library jar: " + libraryJar + ", compiler jar: " + compilerJar override def toString = "Scala instance{version label " + version + ", actual version " + actualVersion + ", " + jarStrings + "}" } @@ -26,7 +26,7 @@ object ScalaInstance def apply(version: String, launcher: xsbti.Launcher): ScalaInstance = apply(version, launcher.getScala(version)) def apply(version: String, provider: xsbti.ScalaProvider): ScalaInstance = - new ScalaInstance(version, provider.loader, provider.libraryJar, provider.compilerJar, (provider.jars.toSet - provider.libraryJar - provider.compilerJar).toSeq) + new ScalaInstance(version, provider.loader, provider.libraryJar, provider.compilerJar, (provider.jars.toSet - provider.libraryJar - provider.compilerJar).toSeq, None) def apply(scalaHome: File, launcher: xsbti.Launcher): ScalaInstance = apply(libraryJar(scalaHome), compilerJar(scalaHome), launcher, extraJars(scalaHome): _*) @@ -36,10 +36,12 @@ object ScalaInstance { val loader = scalaLoader(launcher, libraryJar :: compilerJar :: extraJars.toList) val version = actualVersion(loader)(" (library jar " + libraryJar.getAbsolutePath + ")") - new ScalaInstance(version, loader, libraryJar, compilerJar, extraJars) + new ScalaInstance(version, loader, libraryJar, compilerJar, extraJars, None) } def apply(version: String, libraryJar: File, compilerJar: File, launcher: xsbti.Launcher, extraJars: File*): ScalaInstance = - new ScalaInstance(version, scalaLoader(launcher, libraryJar :: compilerJar :: extraJars.toList), libraryJar, compilerJar, extraJars) + apply(version, None, libraryJar, compilerJar, launcher, extraJars : _*) + def apply(version: String, explicitActual: Option[String], libraryJar: File, compilerJar: File, launcher: xsbti.Launcher, extraJars: File*): ScalaInstance = + new ScalaInstance(version, scalaLoader(launcher, libraryJar :: compilerJar :: extraJars.toList), libraryJar, compilerJar, extraJars, explicitActual) def extraJars(scalaHome: File): Seq[File] = optScalaJar(scalaHome, "jline.jar") ++ optScalaJar(scalaHome, "fjbg.jar")