diff --git a/src/main/scala/sbt/Compile.scala b/src/main/scala/sbt/Compile.scala index c103e4e4b..49a04d209 100644 --- a/src/main/scala/sbt/Compile.scala +++ b/src/main/scala/sbt/Compile.scala @@ -27,8 +27,7 @@ sealed abstract class CompilerCore val classpathSet = fileSet(classpath) val scalaCompile = process("Scala", scalaSources, processScala(scalaSources, classpathSet, outputDirectory.asFile, scalaOptions, log) ) val javaCompile = process("Java", javaSources, processJava(javaSources, classpathSet, outputDirectory.asFile, javaOptions, log)) - try { doCompile(label, sources, outputDirectory, order, log)(javaCompile, scalaCompile) } - catch { case e: xsbti.CompileFailed => log.trace(e); Some(e.toString) } + doCompile(label, sources, outputDirectory, order, log)(javaCompile, scalaCompile) } protected def doCompile(label: String, sources: Iterable[Path], outputDirectory: Path, order: CompileOrder.Value, log: Logger)(javaCompile: () => Unit, scalaCompile: () => Unit) = { @@ -40,14 +39,16 @@ sealed abstract class CompilerCore } else { - FileUtilities.createDirectory(outputDirectory.asFile, log) orElse Control.trapUnit("Compiler error: ", log) - { - val (first, second) = if(order == CompileOrder.JavaThenScala) (javaCompile, scalaCompile) else (scalaCompile, javaCompile) - first() - second() - log.info(actionSuccessfulMessage) - None - } + FileUtilities.createDirectory(outputDirectory.asFile, log) orElse + (try + { + val (first, second) = if(order == CompileOrder.JavaThenScala) (javaCompile, scalaCompile) else (scalaCompile, javaCompile) + first() + second() + log.info(actionSuccessfulMessage) + None + } + catch { case e: xsbti.CompileFailed => Some(e.toString) }) } } def actionStartMessage(label: String): String diff --git a/src/main/scala/sbt/Main.scala b/src/main/scala/sbt/Main.scala index c3db9ff0e..846419578 100644 --- a/src/main/scala/sbt/Main.scala +++ b/src/main/scala/sbt/Main.scala @@ -101,7 +101,7 @@ class xMain extends xsbti.AppMain private def startProject(project: Project, configuration: xsbti.AppConfiguration, remainingArguments: List[String], startTime: Long): xsbti.MainResult = { project.log.info("Building project " + project.name + " " + project.version.toString + " against Scala " + project.buildScalaVersion) - project.log.info(" using " + project.getClass.getName + " with sbt " + project.sbtVersion.value + " and Scala " + project.scalaVersion.value) + project.log.info(" using " + project.getClass.getName + " with sbt " + project.sbtVersion.value + " and Scala " + project.defScalaVersion.value) processArguments(project, initialize(remainingArguments), configuration, startTime) match { @@ -124,7 +124,7 @@ class xMain extends xsbti.AppMain { case "" :: tail => process(project, tail, isInteractive) case (ExitCommand | QuitCommand) :: _ => Exit(NormalExitCode) - case RebootCommand :: tail => Reboot(project.scalaVersion.value, saveProject(tail), configuration) + case RebootCommand :: tail => Reboot(project.defScalaVersion.value, saveProject(tail), configuration) case InteractiveCommand :: _ => process(project, prompt(baseProject, project) :: arguments, true) case SpecificBuild(version, action) :: tail => if(Some(version) != baseProject.info.buildScalaVersion) @@ -514,7 +514,7 @@ class xMain extends xsbti.AppMain property.setStringValue(newValue) property match { - case project.scalaVersion => notePending("Scala ") + case project.defScalaVersion | project.buildScalaVersions => notePending("Scala ") case project.sbtVersion => notePending("sbt ") case _ => Console.println(" Set property '" + name + "' = '" + newValue + "'") } diff --git a/src/main/scala/sbt/Project.scala b/src/main/scala/sbt/Project.scala index e9f8b1567..0f3d5b504 100644 --- a/src/main/scala/sbt/Project.scala +++ b/src/main/scala/sbt/Project.scala @@ -212,21 +212,20 @@ trait Project extends TaskManager with Dag[Project] with BasicEnvironment /** The property for the project's organization. Defaults to the parent project's organization or the project name if there is no parent. */ final val projectOrganization = propertyOptional[String](normalizedName, true) /** The property that defines the version of Scala to use with the project definition. This can be different - * from the version of Scala used to build the project (defined initially by buildInitScalaVersion). + * from the version of Scala used to build the project (current version used is buildScalaVersion, available are in buildScalaVersions). * This property is only read by `sbt` on startup and reload. It is the definitive source for the version of Scala * that sbt and the project definition are using.*/ - final val scalaVersion = property[String] + final val defScalaVersion = property[String] final val sbtVersion = property[String] final val projectInitialize = propertyOptional[Boolean](false) final val projectScratch = propertyOptional[Boolean](false, true) - /** The property that defines the version of Scala to build this project with by default. This can be - * different from the version of Scala used to build and run the project definition (defined by scalaVersion). - * This property is only read by `sbt` on startup and reload. When cross-building, this value may be different from the actual - * version of Scala being used to build the project. info.scalaVersion is always the definitive source for the current Scala version. - * This property should only be used to change the version of Scala used for normal development (not cross-building).*/ - final val buildInitScalaVersion = propertyOptional[String](scalaVersion.value, true) + /** The property that defines the versions of Scala to build this project against as a comma separated string. This can be + * different from the version of Scala used to build and run the project definition (defined by defScalaVersion). + * This property is only read by `sbt` on startup and reload. The definitive source for the version of Scala currently + * being used is buildScalaVersion.*/ + final val buildScalaVersions = propertyOptional[String](defScalaVersion.value, true) /** The definitive source for the version of Scala being used to *build* the project.*/ - def buildScalaVersion = info.buildScalaVersion.getOrElse(buildInitScalaVersion.value) + def buildScalaVersion = info.buildScalaVersion.getOrElse(crossScalaVersions.first) def componentManager = new xsbt.ComponentManager(info.launcher.globalLock, info.app.components, log) def buildScalaInstance = @@ -250,13 +249,12 @@ trait Project extends TaskManager with Dag[Project] with BasicEnvironment /** True if crossPath should be the identity function.*/ protected def disableCrossPaths = crossScalaVersions.isEmpty - /** By default, this is empty and cross-building is disabled. Overriding this to a Set of Scala versions - * will enable cross-building against those versions.*/ - def crossScalaVersions: immutable.Set[String] = + /** By default, this is the build.scala.versions property split around commas. This can be overridden directly if preferred.*/ + def crossScalaVersions: Seq[String] = info.parent match { case Some(p) => p.crossScalaVersions - case None => immutable.Set.empty[String] + case None => buildScalaVersions.value.split("""\s*,\s*""").toList.reverse.removeDuplicates.reverse } /** A `PathFinder` that determines the files watched when an action is run with a preceeding ~ when this is the current * project. This project does not need to include the watched paths for projects that this project depends on.*/