From 330febc72b402aac2460be2cbc212d5860ed205c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 27 Jan 2011 20:24:50 +0000 Subject: Securing some of the blessings of whitespace fo... Securing some of the blessings of whitespace for the sbt build. No review. --- project/build.properties | 4 +- project/build/AdditionalResources.scala | 40 +++--- project/build/BasicLayer.scala | 203 ++++++++++++++++--------------- project/build/BuildInfoEnvironment.scala | 6 +- project/build/Comparator.scala | 10 +- project/build/Compilation.scala | 54 ++++---- project/build/CompilationStep.scala | 22 ++-- project/build/Packer.scala | 62 +++++----- project/build/Partest.scala | 134 ++++++++++---------- project/build/PathConfig.scala | 18 +-- project/build/ScalaBuildProject.scala | 2 +- project/build/ScalaSBTBuilder.scala | 185 ++++++++++++++-------------- project/build/ScalaTools.scala | 42 +++---- project/build/Scaladoc.scala | 16 +-- 14 files changed, 405 insertions(+), 393 deletions(-) diff --git a/project/build.properties b/project/build.properties index 9faf28bc07..39dc158e14 100644 --- a/project/build.properties +++ b/project/build.properties @@ -2,10 +2,10 @@ #Sun Apr 11 14:24:47 CEST 2010 project.name=scala def.scala.version=2.7.7 -sbt.version=0.7.4 +sbt.version=0.7.5.RC0 copyright=Copyright 2002-2011, LAMP/EPFL build.scala.versions=2.7.7 project.initialize=false project.organization=ch.epfl.lamp partest.version.number=0.9.2 -project.version=2.8.0 \ No newline at end of file +project.version=2.8.1 diff --git a/project/build/AdditionalResources.scala b/project/build/AdditionalResources.scala index b9be967fa6..a347e0dbd1 100644 --- a/project/build/AdditionalResources.scala +++ b/project/build/AdditionalResources.scala @@ -11,9 +11,9 @@ trait AdditionalResources { self : BasicLayer => def writeProperties: Option[String] = { - def write0(steps:List[Step]):Option[String]= steps match{ - case x::xs => x match{ - case c:PropertiesToWrite => { + def write0(steps: List[Step]): Option[String] = steps match { + case x :: xs => x match { + case c: PropertiesToWrite => { c.writeProperties orElse write0(xs) } case _ => write0(xs) @@ -28,23 +28,23 @@ object AdditionalResources { /** * A FileFilter that defines what are the files that will be copied */ - lazy val basicFilter = "*.tmpl" | "*.xml"| "*.js"| "*.css" | "*.properties" | "*.swf" | "*.png" - implicit def stringToGlob(s:String):NameFilter=GlobFilter(s) + lazy val basicFilter = "*.tmpl" | "*.xml" | "*.js" | "*.css" | "*.properties" | "*.swf" | "*.png" + implicit def stringToGlob(s: String): NameFilter = GlobFilter(s) } trait ResourcesToCopy { self : CompilationStep => - def getResources(from:Path,filter:FileFilter):PathFinder = (from ##)** filter - def getResources(from:Path):PathFinder = getResources(from,AdditionalResources.basicFilter) + def getResources(from: Path, filter: FileFilter): PathFinder = (from ##)** filter + def getResources(from: Path): PathFinder = getResources(from, AdditionalResources.basicFilter) - def copyDestination:Path - def filesToCopy:PathFinder + def copyDestination: Path + def filesToCopy: PathFinder def copy = { log.info("Copying files for "+name) - try{ - FileUtilities.copy(filesToCopy.get,copyDestination,log) - }catch{ - case e=>Some(e.toString) + try { + FileUtilities.copy(filesToCopy.get, copyDestination, log) + } catch { + case e => Some(e.toString) } None } @@ -53,29 +53,29 @@ trait ResourcesToCopy { trait PropertiesToWrite { self : CompilationStep => - def propertyList:List[Tuple2[String,String]] - def propertyDestination:Path + def propertyList: List[(String, String)] + def propertyDestination: Path - def writeProperties:Option[String]={ + def writeProperties: Option[String] ={ import java.io._ import java.util.Properties val properties = new Properties - def insert(list:List[Tuple2[String,String]]):Unit=list match{ + def insert(list: List[(String, String)]): Unit = list match { case Nil => - case x::xs => { + case x :: xs => { properties setProperty(x._1, x._2) insert(xs) } } - try{ + try { insert(propertyList) val destFile = propertyDestination.asFile val stream = new FileOutputStream(destFile) properties.store(stream, null) - }catch{ + } catch { case e => Some(e.toString) } None diff --git a/project/build/BasicLayer.scala b/project/build/BasicLayer.scala index ee2f5dc681..c4006d9aae 100644 --- a/project/build/BasicLayer.scala +++ b/project/build/BasicLayer.scala @@ -1,41 +1,41 @@ import sbt._ -import xsbt.{ScalaInstance} +import xsbt.ScalaInstance import ScalaBuildProject._ -import scala.collection.immutable.{EmptyMap} /** * Basic tasks and configuration shared by all layers. This class regroups the configuration and behaviour * shared by all layers. * @author Grégory Moix */ -abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previousLayer:Option[BasicLayer]) - extends ScalaBuildProject with ReflectiveProject - with AdditionalResources with LayerCompilation with BuildInfoEnvironment{ - +abstract class BasicLayer(val info: ProjectInfo, val versionNumber: String, previousLayer: Option[BasicLayer]) + extends ScalaBuildProject + with ReflectiveProject + with AdditionalResources + with LayerCompilation + with BuildInfoEnvironment +{ layer => // All path values must be lazy in order to avoid initialization issues (sbt way of doing things) - def buildInfoEnvironmentLocation:Path=outputRootPath / ("build-"+name+".properties") + def buildInfoEnvironmentLocation: Path = outputRootPath / ("build-"+name+".properties") // Support of triggered execution at project level - override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java"|| AdditionalResources.basicFilter) + override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java" || AdditionalResources.basicFilter) override def dependencies = info.dependencies lazy val copyright = property[String] lazy val partestVersionNumber = property[Version] - lazy val nextLayer:Option[BasicLayer]=None - def packingDestination :Path = layerOutput / "pack" - lazy val libsDestination=packingDestination/"lib" - lazy val packedStarrOutput=outputRootPath / "pasta" + lazy val nextLayer: Option[BasicLayer] = None + def packingDestination : Path = layerOutput / "pack" + lazy val libsDestination = packingDestination/ "lib" + lazy val packedStarrOutput = outputRootPath / "pasta" lazy val requiredPluginsDirForCompilation = layerOutput / "misc" / "scala-devel" / "plugins" def compilerAdditionalJars: List[Path] = Nil def libraryAdditionalJars: List[Path] = Nil - - // TASKS /** @@ -43,49 +43,43 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou * was created correctly and compile it if necessary */ lazy val startLayer = previousLayer match { - case Some(previous) => task{ + case Some(previous) => task { None }.dependsOn(previous.finishLayer) - case None => task{None} + case None => task {None} } - def buildLayer:Option[String] = { + def buildLayer: Option[String] = { externalCompilation orElse writeProperties } - lazy val build= task{ + lazy val build = task { buildLayer }.dependsOn(startLayer) - /** * Finish the compilation and ressources copy and generation * It does nothing in itself. As sbt doesn't support conditional dependencies, * it permit locker to override it in order to lock the layer when the compilation * is finished. */ - lazy val finishLayer:ManagedTask = task{None}.dependsOn(build) - + lazy val finishLayer: ManagedTask = task {None}.dependsOn(build) - def cleaningList=layerOutput::layerEnvironment.envBackingPath::packingDestination::Nil + def cleaningList = layerOutput :: layerEnvironment.envBackingPath :: packingDestination :: Nil - def cleanFiles = FileUtilities.clean(cleaningList,true,log) + def cleanFiles = FileUtilities.clean(cleaningList, true, log) - lazy val clean:Task = nextLayer match { - case None => super.task{ cleanFiles}// We use super.task, so cleaning is done in every case, even when locked - case Some(next) => super.task{cleanFiles}.dependsOn{next.clean} + lazy val clean: Task = nextLayer match { + case None => super.task { cleanFiles}// We use super.task, so cleaning is done in every case, even when locked + case Some(next) => super.task {cleanFiles}.dependsOn {next.clean} } - lazy val cleanBuild = task{ + lazy val cleanBuild = task { cleanFiles orElse buildLayer }.dependsOn(startLayer) - - - - // Utility methods (for quick access) def libraryOutput = libraryConfig.outputDirectory def actorsOutput = actorsConfig.outputDirectory @@ -107,7 +101,7 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou /** * Configuration of the core library compilation */ - lazy val libraryConfig = new CompilationStep("library", pathLayout ,log) with ResourcesToCopy with PropertiesToWrite{ + lazy val libraryConfig = new CompilationStep("library", pathLayout , log) with ResourcesToCopy with PropertiesToWrite { def label = "["+layer.name+"] library" def options: Seq[String] = Seq("-sourcepath", pathConfig.sources.absolutePath.toString) def dependencies = Nil @@ -117,32 +111,32 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou def filesToCopy = getResources(srcDir) def propertyDestination = outputDirectory / "library.properties" - def propertyList = ("version.number",versionNumber)::("copyright.string",copyright.value)::Nil + def propertyList = ("version.number",versionNumber) :: ("copyright.string", copyright.value) :: Nil } /** * Configuration of the compiler */ - lazy val compilerConfig = new CompilationStep("compiler", pathLayout, log) with ResourcesToCopy with PropertiesToWrite with Packaging{ + lazy val compilerConfig = new CompilationStep("compiler", pathLayout, log) with ResourcesToCopy with PropertiesToWrite with Packaging { def label = "["+layer.name+"] compiler" private def bootClassPath : String = { System.getProperty("sun.boot.class.path") } override def classpath: PathFinder = super.classpath +++ fjbgJar +++ msilJar +++ jlineJar +++ antJar +++ forkJoinJar - def options = Seq("-bootclasspath",bootClassPath) - def dependencies = if (minimalCompilation) libraryConfig::Nil else libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil + def options = Seq("-bootclasspath", bootClassPath) + def dependencies = if (minimalCompilation) libraryConfig :: Nil else libraryConfig :: actorsConfig :: dbcConfig :: swingConfig :: Nil def copyDestination = outputDirectory def filesToCopy = getResources(srcDir) def propertyDestination = outputDirectory / "compiler.properties" - def propertyList = ("version.number",versionNumber)::("copyright.string",copyright.value)::Nil + def propertyList = ("version.number",versionNumber) :: ("copyright.string", copyright.value) :: Nil lazy val packagingConfig = { import java.util.jar.Manifest import java.io.FileInputStream val manifest = new Manifest(new FileInputStream(manifestPath.asFile)) - new PackagingConfiguration(libsDestination / compilerJarName, List(outputDirectory ##),manifest ,compilerAdditionalJars) + new PackagingConfiguration(libsDestination / compilerJarName, List(outputDirectory ##), manifest , compilerAdditionalJars) } lazy val starrPackagingConfig = new PackagingConfiguration(packedStarrOutput/compilerJarName, List(outputDirectory ##)) @@ -153,36 +147,39 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou /** * Config of the actors library */ - lazy val actorsConfig = new CompilationStep ("actors", pathLayout,log){ + lazy val actorsConfig = new CompilationStep ("actors", pathLayout, log){ def label = "["+layer.name+"] actors library" override def classpath: PathFinder = super.classpath +++ forkJoinJar def options: Seq[String] = Seq() - def dependencies = libraryConfig::Nil + def dependencies = libraryConfig :: Nil } /** * Config of the dbc library */ - lazy val dbcConfig = new CompilationStep("dbc", pathLayout, log) with Packaging{ + lazy val dbcConfig = new CompilationStep("dbc", pathLayout, log) with Packaging { def label = "["+layer.name+"] dbc library" def options: Seq[String] = Seq() - def dependencies = libraryConfig::Nil - - lazy val packagingConfig = new PackagingConfiguration(libsDestination / dbcJarName,List(outputDirectory ##)) + def dependencies = libraryConfig :: Nil + lazy val packagingConfig = new PackagingConfiguration( + libsDestination / dbcJarName, + List(outputDirectory ##) + ) } /** * Config of the swing library */ - lazy val swingConfig = new CompilationStep("swing", pathLayout, log) with Packaging{ + lazy val swingConfig = new CompilationStep("swing", pathLayout, log) with Packaging { def label = "["+layer.name+"] swing library" def options: Seq[String] = Seq() - def dependencies = libraryConfig::actorsConfig::Nil - - lazy val packagingConfig = new PackagingConfiguration(libsDestination / swingJarName,List(outputDirectory ##)) - + def dependencies = libraryConfig :: actorsConfig :: Nil + lazy val packagingConfig = new PackagingConfiguration( + libsDestination / swingJarName, + List(outputDirectory ##) + ) } ///// TOOLS CONFIGURATION //////// @@ -193,32 +190,38 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou lazy val scalacheckConfig = new CompilationStep("scalacheck", pathLayout, log) with Packaging { def label = "["+layer.name+"] scalacheck" def options: Seq[String] = Seq() - def dependencies = libraryConfig::compilerConfig::actorsConfig::Nil + def dependencies = libraryConfig :: compilerConfig :: actorsConfig :: Nil - lazy val packagingConfig = new PackagingConfiguration(libsDestination / scalacheckJarName,List(outputDirectory ##)) + lazy val packagingConfig = new PackagingConfiguration( + libsDestination / scalacheckJarName, + List(outputDirectory ##) + ) } /** * Configuration of scalap tool */ - lazy val scalapConfig = new CompilationStep("scalap", pathLayout,log) with Packaging{ + lazy val scalapConfig = new CompilationStep("scalap", pathLayout, log) with Packaging { def label = "["+layer.name+"] scalap" def options: Seq[String] = Seq() - def dependencies = libraryConfig::compilerConfig::Nil + def dependencies = libraryConfig :: compilerConfig :: Nil - val decoderProperties = (srcDir ## )/ "decoder.properties" + val decoderProperties = (srcDir ## ) / "decoder.properties" - lazy val packagingConfig = new PackagingConfiguration(libsDestination / scalapJarName,List(outputDirectory ##,decoderProperties)) + lazy val packagingConfig = new PackagingConfiguration( + libsDestination / scalapJarName, + List(outputDirectory ##,decoderProperties) + ) } /** * Configuration of the partest tool */ - lazy val partestConfig = new CompilationStep("partest", pathLayout,log) with ResourcesToCopy with PropertiesToWrite with Packaging{ + lazy val partestConfig = new CompilationStep("partest", pathLayout, log) with ResourcesToCopy with PropertiesToWrite with Packaging { def label = "["+layer.name+"] partest" override def classpath: PathFinder = super.classpath +++ antJar +++ forkJoinJar def options: Seq[String] = Seq() - def dependencies = libraryConfig::compilerConfig::scalapConfig::actorsConfig::Nil + def dependencies = libraryConfig :: compilerConfig :: scalapConfig :: actorsConfig :: Nil def copyDestination = outputDirectory def filesToCopy = getResources(srcDir) @@ -226,57 +229,65 @@ abstract class BasicLayer(val info:ProjectInfo,val versionNumber:String, previou def propertyDestination = outputDirectory / "partest.properties" def propertyList = ("version.number",partestVersionNumber.value.toString)::("copyright.string",copyright.value)::Nil - lazy val packagingConfig = new PackagingConfiguration(libsDestination / partestJarName,List(outputDirectory ##)) + lazy val packagingConfig = new PackagingConfiguration(libsDestination / partestJarName, List(outputDirectory ##)) } ///// PLUGINS CONFIGURATION //////// + lazy val continuationPluginConfig = { + val config = new PathConfig { + def projectRoot: Path = pathLayout.projectRoot + def sources: Path = pathLayout.srcDir / "continuations" / "plugin" + def analysis: Path = pathLayout.analysisOutput / "continuations" / "plugin" + def output: Path = pathLayout.classesOutput / "continuations" / "plugin" + } - lazy val continuationPluginConfig = new CompilationStep("continuation-plugin", - new PathConfig{ - def projectRoot:Path = pathLayout.projectRoot - def sources:Path = pathLayout.srcDir / "continuations" / "plugin" - def analysis:Path = pathLayout.analysisOutput / "continuations" / "plugin" - def output:Path = pathLayout.classesOutput / "continuations" / "plugin" - } , - log)with ResourcesToCopy with EarlyPackaging { - def label = "["+layer.name+"] continuation plugin" - def dependencies = libraryConfig::compilerConfig::Nil - override def classpath = super.classpath - def options = Seq() - - def filesToCopy = (sourceRoots##) / "scalac-plugin.xml" - def copyDestination = outputDirectory - def jarContent = List(outputDirectory ##) - lazy val packagingConfig = new PackagingConfiguration(requiredPluginsDirForCompilation/"continuations.jar",List(outputDirectory ##)) - lazy val earlyPackagingConfig= new PackagingConfiguration(pathLayout.outputDir / "misc" / "scala-devel" / "plugins"/"continuations.jar",List(outputDirectory ##)) - + new CompilationStep("continuation-plugin", config, log) with ResourcesToCopy with EarlyPackaging { + def label = "["+layer.name+"] continuation plugin" + def dependencies = libraryConfig :: compilerConfig :: Nil + def options = Seq() + + def filesToCopy = (sourceRoots ##) / "scalac-plugin.xml" + def copyDestination = outputDirectory + def jarContent = List(outputDirectory ##) + lazy val packagingConfig = new PackagingConfiguration( + requiredPluginsDirForCompilation/"continuations.jar", + List(outputDirectory ##) + ) + lazy val earlyPackagingConfig = new PackagingConfiguration( + pathLayout.outputDir / "misc" / "scala-devel" / "plugins" / "continuations.jar", + List(outputDirectory ##) + ) + } } - lazy val continuationLibraryConfig = new CompilationStep("continuation-library", - new PathConfig{ - def projectRoot:Path = pathLayout.projectRoot - def sources:Path = pathLayout.srcDir / "continuations" / "library" - def analysis:Path = pathLayout.analysisOutput / "continuations" / "library" - def output:Path = pathLayout.classesOutput / "continuations" / "library" - }, - log) { - def label = "["+layer.name+"] continuation library" - def dependencies = libraryConfig::compilerConfig::continuationPluginConfig::Nil - def options = Seq("-Xpluginsdir",requiredPluginsDirForCompilation.absolutePath,"-Xplugin-require:continuations","-P:continuations:enable") - + lazy val continuationLibraryConfig = { + val config = new PathConfig { + def projectRoot: Path = pathLayout.projectRoot + def sources: Path = pathLayout.srcDir / "continuations" / "library" + def analysis: Path = pathLayout.analysisOutput / "continuations" / "library" + def output: Path = pathLayout.classesOutput / "continuations" / "library" + } + + new CompilationStep("continuation-library", config, log) { + def label = "["+layer.name+"] continuation library" + def dependencies = libraryConfig :: compilerConfig :: continuationPluginConfig :: Nil + def options = Seq( + "-Xpluginsdir", + requiredPluginsDirForCompilation.absolutePath, + "-Xplugin-require:continuations", + "-P:continuations:enable" + ) + } } - - - // Grouping compilation steps def minimalCompilation = false // It must be true for locker because we do not need to compile everything - def libraryWS:WrapperStep with Packaging - def toolsWS:WrapperStep - lazy val pluginsWS = new WrapperStep(continuationPluginConfig::continuationLibraryConfig::Nil) + def libraryWS: WrapperStep with Packaging + def toolsWS: WrapperStep - lazy val allSteps = new WrapperStep(libraryWS::compilerConfig::pluginsWS::toolsWS::Nil) + lazy val pluginsWS = new WrapperStep(continuationPluginConfig :: continuationLibraryConfig :: Nil) + lazy val allSteps = new WrapperStep(libraryWS :: compilerConfig :: pluginsWS :: toolsWS :: Nil) } diff --git a/project/build/BuildInfoEnvironment.scala b/project/build/BuildInfoEnvironment.scala index 682b8af5da..a7f3d4ba96 100644 --- a/project/build/BuildInfoEnvironment.scala +++ b/project/build/BuildInfoEnvironment.scala @@ -1,7 +1,7 @@ import sbt._ -trait BuildInfoEnvironment{ +trait BuildInfoEnvironment { self : Project => - def buildInfoEnvironmentLocation:Path + def buildInfoEnvironmentLocation: Path /** * Environment for storing properties that * 1) need to be saved across sbt session @@ -15,7 +15,7 @@ trait BuildInfoEnvironment{ // the properties file will be read/stored def envBackingPath = buildInfoEnvironmentLocation // define some properties - lazy val lastCompilerVersion:Property[String] = propertyOptional[String]("") + lazy val lastCompilerVersion: Property[String] = propertyOptional[String]("") } } diff --git a/project/build/Comparator.scala b/project/build/Comparator.scala index 8b5d65d157..32b1a516c6 100644 --- a/project/build/Comparator.scala +++ b/project/build/Comparator.scala @@ -1,15 +1,15 @@ import sbt._ -import java.io.{File,FileInputStream} +import java.io.{File, FileInputStream} // Based on scala.tools.ant.Same object Comparator { - private def getMappedPath(path:Path,baseDirectory:Path):Path= { - Path.fromString(baseDirectory,path.relativePath) + private def getMappedPath(path: Path, baseDirectory: Path): Path = { + Path.fromString(baseDirectory, path.relativePath) } - def compare(origin:Path,dest:Path,filter:Path=>PathFinder,log:Logger):Option[String] = { + def compare(origin: Path, dest: Path, filter: Path => PathFinder, log: Logger): Option[String] = { log.info("Comparing the contents of "+origin.absolutePath+ " with "+dest.absolutePath) var allEqualNow = true @@ -33,7 +33,7 @@ object Comparator { for (originPath <- originPaths.filter(! _.isDirectory)){ log.debug("origin :" + originPath.absolutePath) - val destPath = getMappedPath(originPath,dest) + val destPath = getMappedPath(originPath, dest) log.debug("dest :" + destPath.absolutePath) var equalNow = true val originFile = originPath.asFile diff --git a/project/build/Compilation.scala b/project/build/Compilation.scala index 2b67f3e5a0..116a25d979 100644 --- a/project/build/Compilation.scala +++ b/project/build/Compilation.scala @@ -1,5 +1,5 @@ import sbt._ -import xsbt.{AnalyzingCompiler,ScalaInstance} +import xsbt.{AnalyzingCompiler, ScalaInstance} import FileUtilities._ /** @@ -12,47 +12,46 @@ trait Compilation { def lastUsedCompilerVersion = layerEnvironment.lastCompilerVersion - def instantiationCompilerJar:Path - def instantiationLibraryJar:Path + def instantiationCompilerJar: Path + def instantiationLibraryJar: Path - - def instanceScope[A](action: ScalaInstance => A):A={ + def instanceScope[A](action: ScalaInstance => A): A = { val instance = ScalaInstance(instantiationLibraryJar.asFile, instantiationCompilerJar.asFile, info.launcher, msilJar.asFile, fjbgJar.asFile) log.debug("Compiler will be instantiated by :" +instance.compilerJar +" and :" +instance.libraryJar ) action(instance) } - def compile(stepList:Step,clean:()=>Option[String]):Option[String]=compile(stepList,Some(clean)) - def compile(stepList:Step):Option[String]=compile(stepList,None) + def compile(stepList: Step, clean:() => Option[String]): Option[String] = compile(stepList, Some(clean)) + def compile(stepList: Step): Option[String] = compile(stepList, None) /** * Execute the different compilation parts one after the others. */ - def compile(stepsList:Step,clean:Option[()=>Option[String]]):Option[String]={ + def compile(stepsList: Step, clean: Option[() => Option[String]]): Option[String] ={ instanceScope[Option[String]]{ scala => - lazy val analyzing = new AnalyzingCompiler(scala,componentManager,xsbt.ClasspathOptions.manual,log) + lazy val analyzing = new AnalyzingCompiler(scala, componentManager, xsbt.ClasspathOptions.manual, log) - def compilerVersionHasChanged:Boolean={ + def compilerVersionHasChanged: Boolean ={ val lastVersion = lastUsedCompilerVersion.value !(lastVersion.compareTo(scala.actualVersion) == 0) } - def checkAndClean(cleanFunction:()=>Option[String]):Option[String]={ + def checkAndClean(cleanFunction:() => Option[String]): Option[String] ={ if (compilerVersionHasChanged){ log.info("The compiler version used to build this layer has changed since last time or this is a clean build.") lastUsedCompilerVersion.update(scala.actualVersion) layerEnvironment.saveEnvironment cleanFunction() - }else{ + } else { log.debug("The compiler version is unchanged. No need for cleaning.") None } } - def compile0(steps:List[Step]):Option[String]= steps match{ - case x::xs => x match{ - case c:CompilationStep => { + def compile0(steps: List[Step]): Option[String] = steps match { + case x :: xs => x match { + case c: CompilationStep => { val conditional = new CompileConditional(c, analyzing) log.info("") conditional.run orElse copy(c) orElse earlyPackaging(c) orElse compile0(xs) @@ -66,21 +65,21 @@ trait Compilation { * When we finishe to compile a step we want to jar if necessary in order to * be able to load plugins for the associated library */ - def earlyPackaging(step:CompilationStep):Option[String]= step match { - case s:EarlyPackaging => { + def earlyPackaging(step: CompilationStep): Option[String] = step match { + case s: EarlyPackaging => { val c = s.earlyPackagingConfig log.debug("Creating jar for plugin") - jar(c.content.flatMap(Packer.jarPattern(_)),c.jarDestination,c.manifest, false, log) + jar(c.content.flatMap(Packer.jarPattern(_)), c.jarDestination, c.manifest, false, log) } case _ => None } - def copy(step:CompilationStep):Option[String]= step match { - case s:ResourcesToCopy => s.copy + def copy(step: CompilationStep): Option[String] = step match { + case s: ResourcesToCopy => s.copy case _ => None } - def cleanIfNecessary:Option[String] = clean match{ + def cleanIfNecessary: Option[String] = clean match { case None => None case Some(f) => checkAndClean(f) } @@ -91,23 +90,22 @@ trait Compilation { } -trait LayerCompilation extends Compilation{ +trait LayerCompilation extends Compilation { self : BasicLayer => - protected def cleanCompilation:Option[String]= { + protected def cleanCompilation: Option[String] = { log.info("Cleaning the products of the compilation.") - FileUtilities.clean(layerOutput::Nil,true,log) + FileUtilities.clean(layerOutput :: Nil, true, log) } /** * Run the actual compilation. Should not be called directly because it is executed on the same jvm and that * it could lead to memory issues. It is used only when launching a new sbt process to do the compilation. */ - lazy val compilation = task{compile(allSteps,cleanCompilation _)} + lazy val compilation = task {compile(allSteps, cleanCompilation _)} - def externalCompilation:Option[String] = { - val runner = new ExternalTaskRunner(projectRoot,this.name,compilation.name,"Error during external compilation", log) + def externalCompilation: Option[String] = { + val runner = new ExternalTaskRunner(projectRoot, this.name, compilation.name, "Error during external compilation", log) runner.runTask } - } diff --git a/project/build/CompilationStep.scala b/project/build/CompilationStep.scala index f9602b2718..d5fdb73f8c 100644 --- a/project/build/CompilationStep.scala +++ b/project/build/CompilationStep.scala @@ -2,15 +2,15 @@ import sbt._ import AdditionalResources._ trait Step extends Dag[Step] { - def dependencies:Iterable[Step] + def dependencies: Iterable[Step] } -class WrapperStep(contents:List[Step]) extends Step{ +class WrapperStep(contents: List[Step]) extends Step { def dependencies = contents } -abstract class CompilationStep(val name:String, val pathConfig:PathConfig, logger:Logger) extends CompileConfiguration with Step { - def this(name:String, layout:PathLayout,logger:Logger) = this(name, layout / name, logger) +abstract class CompilationStep(val name: String, val pathConfig: PathConfig, logger: Logger) extends CompileConfiguration with Step { + def this(name: String, layout: PathLayout, logger: Logger) = this(name, layout / name, logger) // Utility methods (for quick access, ...) final def srcDir = pathConfig.sources @@ -23,17 +23,17 @@ abstract class CompilationStep(val name:String, val pathConfig:PathConfig, logge final def analysisPath: Path = pathConfig.analysis final def outputDirectory: Path = pathConfig.output def classpath = { - def addDependenciesOutputTo(list:List[Step],acc:PathFinder):PathFinder = list match{ + def addDependenciesOutputTo(list: List[Step], acc: PathFinder): PathFinder = list match { case Nil => acc - case x::xs => x match{ - case c:CompilationStep => addDependenciesOutputTo(xs,acc +++ c.outputDirectory) - case w:WrapperStep => addDependenciesOutputTo(xs, addDependenciesOutputTo(dependencies.toList,acc)) + case x :: xs => x match { + case c: CompilationStep => addDependenciesOutputTo(xs, acc +++ c.outputDirectory) + case w: WrapperStep => addDependenciesOutputTo(xs, addDependenciesOutputTo(dependencies.toList, acc)) } } - addDependenciesOutputTo(dependencies.toList,outputDirectory) + addDependenciesOutputTo(dependencies.toList, outputDirectory) } - def javaOptions: Seq[String] = Seq ("-target","1.5","-source","1.5","-g:none") + def javaOptions: Seq[String] = "-target 1.5 -source 1.5 -g:none" split ' ' def maxErrors: Int = 100 def compileOrder = CompileOrder.JavaThenScala - def fingerprints = Fingerprints(Nil,Nil) + def fingerprints = Fingerprints(Nil, Nil) } diff --git a/project/build/Packer.scala b/project/build/Packer.scala index 92df80299b..fde5a732a9 100644 --- a/project/build/Packer.scala +++ b/project/build/Packer.scala @@ -1,5 +1,5 @@ import sbt._ -import java.io.{File,FileInputStream} +import java.io.{File, FileInputStream} import java.util.jar.Manifest import AdditionalResources._ import FileUtilities._ @@ -13,17 +13,17 @@ object Packer { */ // We must exclude the manifest because we generate it automatically, and when we add multiples other jars, they could have // also a manifest files each, resulting in conflicts for the FileUtilities.jar(..) method - def jarPattern(path:PathFinder) = path.descendentsExcept(AllPassFilter, (".*" - ".") || HiddenFileFilter || new ExactFilter("MANIFEST.MF")).get + def jarPattern(path: PathFinder) = path.descendentsExcept(AllPassFilter, (".*" - ".") || HiddenFileFilter || new ExactFilter("MANIFEST.MF")).get - def createJar(j:Packaging,log:Logger):Option[String]=createJar(j.packagingConfig,log,jarPattern _,true) - def createJar(j:PackagingConfiguration,log:Logger):Option[String]=createJar(j,log,jarPattern _,true) + def createJar(j: Packaging, log: Logger): Option[String] = createJar(j.packagingConfig, log, jarPattern _, true) + def createJar(j: PackagingConfiguration, log: Logger): Option[String] = createJar(j, log, jarPattern _, true) /** * Create a jar from the packaging trait. Is able to add directly others jars to it */ - def createJar(j:PackagingConfiguration,log:Logger,filter:(PathFinder)=>Iterable[Path],addIncludedLibs:Boolean):Option[String] = { - def pack0(content:Iterable[Path])=jar(content.flatMap(filter(_)),j.jarDestination, j.manifest, false, log) + def createJar(j: PackagingConfiguration, log: Logger, filter:(PathFinder) => Iterable[Path], addIncludedLibs: Boolean): Option[String] = { + def pack0(content: Iterable[Path])= jar(content.flatMap(filter(_)), j.jarDestination, j.manifest, false, log) j.jarsToInclude match { case Nil => pack0(j.content) @@ -31,8 +31,8 @@ object Packer { withTemporaryDirectory(log) { tmp: File => val tmpPath = Path.fromFile(tmp) log.debug("List of jars to be added : " +list) - def unzip0(l:List[Path]):Option[String] = l match { - case x::xs => {unzip(x,tmpPath,log);unzip0(xs)} //TODO properly handle failing of unzip + def unzip0(l: List[Path]): Option[String] = l match { + case x :: xs => {unzip(x, tmpPath, log);unzip0(xs)} //TODO properly handle failing of unzip case Nil => None } unzip0(list) @@ -54,17 +54,17 @@ object Packer { trait Packer { self: BasicLayer => - def libraryToCopy:List[Path] = Nil + def libraryToCopy: List[Path] = Nil /** * The actual pack task. */ - def packF= { + def packF = { import Packer._ - def iterate(steps:List[Step]):Option[String]= steps match{ - case x::xs => x match{ - case c:Packaging => { - createJar(c,log) orElse iterate(xs) + def iterate(steps: List[Step]): Option[String] = steps match { + case x :: xs => x match { + case c: Packaging => { + createJar(c, log) orElse iterate(xs) } case _ => iterate(xs) } @@ -72,8 +72,8 @@ trait Packer { } def copy0 ={ - copyFile(manifestPath,packingDestination/"META-INF"/"MANIFEST.MF",log) orElse { - copy(libraryToCopy,packingDestination , true,true,log) match { + copyFile(manifestPath,packingDestination/"META-INF"/"MANIFEST.MF", log) orElse { + copy(libraryToCopy, packingDestination , true, true, log) match { case Right(_) => None case Left(e) => Some(e) } @@ -81,31 +81,31 @@ trait Packer { } iterate(allSteps.topologicalSort) orElse copy0 } - lazy val pack=task{packF}.dependsOn(finishLayer) + lazy val pack = task {packF}.dependsOn(finishLayer) } -class PackagingConfiguration(val jarDestination:Path, val content:Iterable[Path],val manifest:Manifest,val jarsToInclude:List[Path]){ - def this(jarDestination:Path,content:Iterable[Path])=this(jarDestination,content, new Manifest,Nil) - def this(jarDestination:Path,content:Iterable[Path],jarsToInclude:List[Path])=this(jarDestination,content,new Manifest, jarsToInclude) +class PackagingConfiguration(val jarDestination: Path, val content: Iterable[Path], val manifest: Manifest, val jarsToInclude: List[Path]){ + def this(jarDestination: Path, content: Iterable[Path])= this(jarDestination, content, new Manifest, Nil) + def this(jarDestination: Path, content: Iterable[Path], jarsToInclude: List[Path])= this(jarDestination, content, new Manifest, jarsToInclude) } -trait Packaging extends Step{ - def packagingConfig:PackagingConfiguration +trait Packaging extends Step { + def packagingConfig: PackagingConfiguration } trait WrapperPackaging extends Packaging { self : WrapperStep => def jarContent = { - def getContent(list:List[Step],acc:List[Path]):List[Path]= list match { + def getContent(list: List[Step], acc: List[Path]): List[Path] = list match { case Nil => acc - case x::xs => x match { - case w:WrapperStep => getContent(xs,getContent(w.dependencies.toList,acc)) - case c:CompilationStep => getContent(xs,(c.outputDirectory ##)::acc) + case x :: xs => x match { + case w: WrapperStep => getContent(xs, getContent(w.dependencies.toList, acc)) + case c: CompilationStep => getContent(xs, (c.outputDirectory ##) :: acc) } } - getContent(dependencies.toList,Nil) + getContent(dependencies.toList, Nil) } } @@ -114,9 +114,9 @@ trait WrapperPackaging extends Packaging { * compilation of the step has finished. It permits to have use libraries that are build using a plugin. (The plugin must * be a jar in order to be recognised by the compiler. */ -trait EarlyPackaging extends Packaging{ - self:CompilationStep => - //def earlyPackagingDestination:Path +trait EarlyPackaging extends Packaging { + self: CompilationStep => + //def earlyPackagingDestination: Path //def earlyJarDestination = earlyPackagingDestination / jarName - def earlyPackagingConfig:PackagingConfiguration + def earlyPackagingConfig: PackagingConfiguration } diff --git a/project/build/Partest.scala b/project/build/Partest.scala index 3ff5c16324..33d601e7ac 100755 --- a/project/build/Partest.scala +++ b/project/build/Partest.scala @@ -3,30 +3,30 @@ import java.io.File import java.net.URLClassLoader import TestSet.{filter} -class TestSet(val SType:TestSetType.Value,val kind:String, val description:String,val files:Array[File]){ +class TestSet(val SType: TestSetType.Value, val kind: String, val description: String, val files: Array[File]){ /** * @param a list of file that we want to know wheter they are members of the test set or not * @return two lists : the first contains files that are member of the test set, the second contains the files that aren't */ - def splitContent(f:List[File]):(List[File],List[File]) = { - f.partition((f:File) => files.elements.exists((e:File)=> f==e)) + def splitContent(f: List[File]):(List[File], List[File]) = { + f.partition((f: File) => files.elements.exists((e: File) => f == e)) } } object TestSet { - def apply(sType:TestSetType.Value,kind:String,description:String,files:PathFinder)= new TestSet(sType,kind,description,filter(files)) - def filter(p:PathFinder):Array[File]=( p --- p **(HiddenFileFilter || GlobFilter("*.obj")||GlobFilter("*.log"))).getFiles.toArray + def apply(sType: TestSetType.Value, kind: String, description: String, files: PathFinder)= new TestSet(sType, kind, description, filter(files)) + def filter(p: PathFinder): Array[File] =( p --- p **(HiddenFileFilter || GlobFilter("*.obj")||GlobFilter("*.log"))).getFiles.toArray } object TestSetType extends Enumeration { - val Std,Continuations = Value + val Std, Continuations = Value } -class TestConfiguration(val library:Path, val classpath:Iterable[Path], val testRoot:Path, - val tests:List[TestSet],val junitReportDir:Option[Path]){ +class TestConfiguration(val library: Path, val classpath: Iterable[Path], val testRoot: Path, + val tests: List[TestSet], val junitReportDir: Option[Path]){ } -trait PartestRunner{ +trait PartestRunner { self: BasicLayer with Packer => import Partest.runTest @@ -51,19 +51,32 @@ trait PartestRunner{ lazy val negContinuationTest = TestSet(Continuations,"neg", "Compiling continuations files that are expected to fail", testFiles / "continuations-neg" * ("*.scala" || DirectoryFilter)) lazy val runContinuationTest = TestSet(Continuations,"run", "Compiling and running continuations files", testFiles / "continuations-run" ** ("*.scala" )) - lazy val continuationScalaOpts = "-Xpluginsdir "+continuationPluginConfig.packagingConfig.jarDestination.asFile.getParent+" -Xplugin-require:continuations -P:continuations:enable" + lazy val continuationScalaOpts = ( + "-Xpluginsdir " + + continuationPluginConfig.packagingConfig.jarDestination.asFile.getParent + + " -Xplugin-require:continuations -P:continuations:enable" + ) - lazy val testSuiteFiles:List[TestSet] = List(posFilesTest,negFilesTest,runFilesTest,jvmFilesTest,resFilesTest,buildmanagerFilesTest,scalacheckFilesTest,shootoutFilesTest,scalapFilesTest,specializedFilesTest) - lazy val testSuiteContinuation:List[TestSet]=List(negContinuationTest,runContinuationTest) + lazy val testSuiteFiles: List[TestSet] = List( + posFilesTest, negFilesTest, runFilesTest, jvmFilesTest, resFilesTest, + buildmanagerFilesTest, scalacheckFilesTest, shootoutFilesTest, scalapFilesTest, + specializedFilesTest + ) + lazy val testSuiteContinuation: List[TestSet] = List(negContinuationTest, runContinuationTest) - private lazy val filesTestMap:Map[String,TestSet] = - Map(testSuiteFiles.map(s=> (s.kind,s) ):_*)+ (("continuations-neg",negContinuationTest),("continuations-run",runContinuationTest)) + private lazy val filesTestMap: Map[String, TestSet] = + Map(testSuiteFiles.map(s => (s.kind,s) ):_*)+ (("continuations-neg",negContinuationTest),("continuations-run", runContinuationTest)) private lazy val partestOptions = List("-failed") - private lazy val partestCompletionList = filesTestMap.keys.toList:::partestOptions:::filesTestMap.values.toList.flatMap{_.files.map(_.toString.substring(testFiles.asFile.toString.length+1))} + private lazy val partestCompletionList: Seq[String] = { + val len = testFiles.asFile.toString.length + 1 - private def runPartest(tests:List[TestSet],scalacOpts:Option[String], failedOnly:Boolean) = { + filesTestMap.keys.toList ++ partestOptions ++ + (filesTestMap.values.toList flatMap (_.files) map (_.toString take len)) + } + + private def runPartest(tests: List[TestSet], scalacOpts: Option[String], failedOnly: Boolean) = { val config = new TestConfiguration( outputLibraryJar, @@ -104,45 +117,43 @@ trait PartestRunner{ args => var failedOnly = false - - def setOptions(options:List[String],acc:List[String]):List[String]= options match{ - case x::xs => x match{ - case "-failed" => {failedOnly= true; log.info("Only tests that failed previously will be run"); setOptions(xs,acc)} - case _ => setOptions(xs,x::acc) - - } - case Nil => acc + def setOptions(options: List[String], acc: List[String]): List[String] = options match { + case "-failed" :: xs => + failedOnly = true + log.info("Only tests that failed previously will be run") + setOptions(xs, acc) + case x :: xs => + setOptions(xs, x :: acc) + case _ => acc } - - - def resolveSets(l:List[String],rem:List[String],acc:List[TestSet]): (List[String], List[TestSet]) = { - def searchSet(arg:String):Option[TestSet] = { + def resolveSets(l: List[String], rem: List[String], acc: List[TestSet]): (List[String], List[TestSet]) = { + def searchSet(arg: String): Option[TestSet] = { filesTestMap.get(arg) } - l match{ - case x::xs => searchSet(x) match{ - case Some(s)=> resolveSets(xs,rem,s::acc) - case None => resolveSets(xs,x::rem,acc) + l match { + case x :: xs => searchSet(x) match { + case Some(s) => resolveSets(xs, rem, s :: acc) + case None => resolveSets(xs, x :: rem, acc) } - case Nil => (rem,acc) + case Nil => (rem, acc) } } - def resolveFiles(l:List[String],sets:List[TestSet]):(List[String],List[TestSet]) = { - def resolve0(filesToResolve:List[File],setsToSearchIn:List[TestSet],setAcc:List[TestSet]):(List[String],List[TestSet])= { + def resolveFiles(l: List[String], sets: List[TestSet]):(List[String], List[TestSet]) = { + def resolve0(filesToResolve: List[File], setsToSearchIn: List[TestSet], setAcc: List[TestSet]):(List[String], List[TestSet])= { filesToResolve match { - case Nil => (Nil,setAcc) // If we have no files left to resolve, we can return the list of the set we have + case Nil => (Nil, setAcc) // If we have no files left to resolve, we can return the list of the set we have case list => { setsToSearchIn match { - case Nil => (list.map(_.toString),setAcc)// If we already had search all sets to find a match, we return the list of the files that where problematic and the set we have - case x::xs => { - val (found, notFound)=x.splitContent(list) + case Nil => (list.map(_.toString), setAcc)// If we already had search all sets to find a match, we return the list of the files that where problematic and the set we have + case x :: xs => { + val (found, notFound)= x.splitContent(list) if(!found.isEmpty){ - val newSet = new TestSet(x.SType,x.kind,x.description,found.toArray) - resolve0(notFound,xs,newSet::setAcc) - }else{ - resolve0(notFound,xs,setAcc) + val newSet = new TestSet(x.SType, x.kind, x.description, found.toArray) + resolve0(notFound, xs, newSet :: setAcc) + } else { + resolve0(notFound, xs, setAcc) } } } @@ -151,19 +162,19 @@ trait PartestRunner{ } - resolve0(l.map(Path.fromString(testFiles,_).asFile),filesTestMap.values.toList,sets) + resolve0(l.map(Path.fromString(testFiles, _).asFile), filesTestMap.values.toList, sets) } - val keys = setOptions(args.toList,Nil) + val keys = setOptions(args.toList, Nil) - if (keys.length == 0) task{runPartest(testSuiteFiles,None,failedOnly) orElse runPartest(testSuiteContinuation,None,failedOnly)} // this is the case where there were only config options, we will run the standard test suite + if (keys.length == 0) task {runPartest(testSuiteFiles, None, failedOnly) orElse runPartest(testSuiteContinuation, None, failedOnly)} // this is the case where there were only config options, we will run the standard test suite else { - val (fileNames, sets) =resolveSets(keys,Nil,Nil) - val (notFound,allSets)=resolveFiles(fileNames,sets) + val (fileNames, sets) = resolveSets(keys, Nil, Nil) + val (notFound, allSets)= resolveFiles(fileNames, sets) if (!notFound.isEmpty) log.info("Don't know what to do with : \n"+notFound.mkString("\n")) val (std, continuations) = allSets.partition(_.SType == TestSetType.Std) - task{runPartest(std,None,failedOnly) orElse runPartest(continuations,Some(continuationScalaOpts),failedOnly)} + task {runPartest(std, None, failedOnly) orElse runPartest(continuations, Some(continuationScalaOpts), failedOnly)} } }.completeWith(partestCompletionList) @@ -192,7 +203,7 @@ object Partest { runner.getClass.getMethod("reflectiveRunTestsForFiles", Array(classOf[Array[File]], classOf[String]): _*) def runTestsForFiles(kindFiles: Array[File], kind: String) = { - val result = runMethod.invoke(runner, Array(kindFiles, kind): _*).asInstanceOf[java.util.HashMap[String,Int]] + val result = runMethod.invoke(runner, Array(kindFiles, kind): _*).asInstanceOf[java.util.HashMap[String, Int]] scala.collection.jcl.Conversions.convertMap(result) } @@ -219,7 +230,7 @@ object Partest { setFileManagerStringProperty("JAVACMD", javacmd.get.getAbsolutePath) if (!javaccmd.isEmpty) setFileManagerStringProperty("JAVAC_CMD", "javac") - setFileManagerStringProperty("CLASSPATH",(config.classpath.map(_.absolutePath).mkString(File.pathSeparator))) + setFileManagerStringProperty("CLASSPATH", (config.classpath.map(_.absolutePath).mkString(File.pathSeparator))) setFileManagerStringProperty("LATEST_LIB", config.library.absolutePath) setFileManagerStringProperty("SCALAC_OPTS", scalacOpts getOrElse "") @@ -232,10 +243,10 @@ object Partest { def resultsToStatistics(results: Iterable[(_, Int)]): (Int, Int) = { val (files, failures) = results map (_._2 == 0) partition (_ == true) - def count(i:Iterable[_]):Int={ + def count(i: Iterable[_]): Int ={ var c = 0 - for (elem <-i) yield{ - c=c+1 + for (elem <-i) yield { + c = c+1 } c } @@ -243,7 +254,7 @@ object Partest { } - def runSet(set: TestSet): (Int, Int,Iterable[String]) = { + def runSet(set: TestSet): (Int, Int, Iterable[String]) = { val (files, name, msg) = (set.files, set.kind, set.description) log.debug("["+name+"] "+ msg+files.mkString(", files :\n","\n","")) if (files.isEmpty) { @@ -260,10 +271,10 @@ object Partest { case (path, 2) => path + " [TIMOUT]" }) - val r=(succs, fails, failed) + val r =(succs, fails, failed) - config.junitReportDir match{ - case Some(d)=> { + config.junitReportDir match { + case Some(d) => { val report = testReport(name, results, succs, fails) scala.xml.XML.save(d/name+".xml", report) } @@ -279,8 +290,7 @@ object Partest { val allFailures = _results.map (_._2).foldLeft(0)( _ + _ ) val allFailedPaths = _results flatMap (_._3) - - def f(msg:String):Option[String] = + def f(msg: String): Option[String] = if (errorOnFailed && allFailures > 0) { Some(msg) } @@ -299,7 +309,7 @@ object Partest { } private def oneResult(res: (String, Int)) = - { + { res._2 match { case 0 => scala.xml.NodeSeq.Empty case 1 => @@ -308,7 +318,7 @@ object Partest { } private def testReport(kind: String, results: Iterable[(String, Int)], succs: Int, fails: Int) = - + { results.map(oneResult(_)) diff --git a/project/build/PathConfig.scala b/project/build/PathConfig.scala index b5cce66a2c..eccd0faf07 100644 --- a/project/build/PathConfig.scala +++ b/project/build/PathConfig.scala @@ -6,10 +6,10 @@ import sbt._ * @author Grégory Moix */ abstract class PathConfig { - def projectRoot:Path - def sources:Path - def analysis:Path - def output:Path + def projectRoot: Path + def sources: Path + def analysis: Path + def output: Path } object PathConfig { @@ -17,25 +17,25 @@ object PathConfig { val analysis = "analysis" } -trait SimpleOutputLayout{ - def outputDir:Path +trait SimpleOutputLayout { + def outputDir: Path lazy val classesOutput = outputDir / PathConfig.classes lazy val analysisOutput = outputDir / PathConfig.analysis } -class PathLayout(val projectRoot:Path, val outputDir:Path) extends SimpleOutputLayout { +class PathLayout(val projectRoot: Path, val outputDir: Path) extends SimpleOutputLayout { lazy val srcDir = projectRoot / "src" /** * An utility method to easily create StandardPathConfig from a given path layout */ - def /(name:String)= new StandardPathConfig(this, name) + def /(name: String)= new StandardPathConfig(this, name) } /** * */ -class StandardPathConfig(layout: PathLayout, name:String) extends PathConfig{ +class StandardPathConfig(layout: PathLayout, name: String) extends PathConfig { lazy val projectRoot = layout.projectRoot lazy val sources = layout.srcDir / name lazy val analysis = layout.analysisOutput / name diff --git a/project/build/ScalaBuildProject.scala b/project/build/ScalaBuildProject.scala index 175f164fe8..4e388c9102 100644 --- a/project/build/ScalaBuildProject.scala +++ b/project/build/ScalaBuildProject.scala @@ -2,7 +2,7 @@ import sbt._ import ScalaBuildProject._ -abstract class ScalaBuildProject extends Project{ +abstract class ScalaBuildProject extends Project { lazy val projectRoot = info.projectPath lazy val layerOutput = outputRootPath / name lazy val pathLayout = new PathLayout(projectRoot, layerOutput) diff --git a/project/build/ScalaSBTBuilder.scala b/project/build/ScalaSBTBuilder.scala index 34edb77911..8f017c3b38 100644 --- a/project/build/ScalaSBTBuilder.scala +++ b/project/build/ScalaSBTBuilder.scala @@ -20,21 +20,21 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java"||AdditionalResources.basicFilter) // Support of triggered execution at top level // Top Level Tasks - lazy val build = task{None}.dependsOn(quick.binPack,quick.binQuick).describedAs(buildTaskDescription) - lazy val clean = quick.clean.dependsOn(libs.clean).describedAs(cleanTaskDescription) - lazy val cleanAll = locker.clean.dependsOn(libs.clean).describedAs(cleanAllTaskDescription) - lazy val docs = quick.scaladoc.describedAs(docsTaskDescription) - lazy val palo = locker.pack.describedAs(paloTaskDescription) - lazy val pasta = quick.pasta.describedAs(pastaTaskDescription) - lazy val newStarr = quick.newStarr.describedAs(newStarrTaskDescription) - lazy val newLocker=locker.newLocker.describedAs(newLockerTaskDescription) - lazy val buildForkjoin=libs.buildForkjoin.describedAs(buildForkjoinTaskDescription) - lazy val newForkjoin = libs.newForkjoin.describedAs(newForkjoinTaskDescription) - lazy val buildFjbg = libs.buildFjbg.describedAs(buildFjbgTaskDescription) - lazy val newFjbg = libs.newFjbg.describedAs(newFjbgTaskDescription) - lazy val buildMsil = libs.buildMsil.describedAs(buildMislTaskDescription) - lazy val newMsil = libs.newMsil.describedAs(newMsilTaskDescription) - lazy val partest = quick.externalPartest.describedAs(partestTaskDescription) + lazy val build = task {None}.dependsOn(quick.binPack, quick.binQuick).describedAs(buildTaskDescription) + lazy val buildFjbg = libs.buildFjbg.describedAs(buildFjbgTaskDescription) + lazy val buildForkjoin = libs.buildForkjoin.describedAs(buildForkjoinTaskDescription) + lazy val buildMsil = libs.buildMsil.describedAs(buildMislTaskDescription) + lazy val clean = quick.clean.dependsOn(libs.clean).describedAs(cleanTaskDescription) + lazy val cleanAll = locker.clean.dependsOn(libs.clean).describedAs(cleanAllTaskDescription) + lazy val docs = quick.scaladoc.describedAs(docsTaskDescription) + lazy val newFjbg = libs.newFjbg.describedAs(newFjbgTaskDescription) + lazy val newForkjoin = libs.newForkjoin.describedAs(newForkjoinTaskDescription) + lazy val newLocker = locker.newLocker.describedAs(newLockerTaskDescription) + lazy val newMsil = libs.newMsil.describedAs(newMsilTaskDescription) + lazy val newStarr = quick.newStarr.describedAs(newStarrTaskDescription) + lazy val palo = locker.pack.describedAs(paloTaskDescription) + lazy val partest = quick.externalPartest.describedAs(partestTaskDescription) + lazy val pasta = quick.pasta.describedAs(pastaTaskDescription) lazy val stabilityTest = strap.stabilityTest.describedAs(stabilityTestTaskDescription) // Top level variables @@ -44,7 +44,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj * the first time it is needed, meaning that this number will be kept * until sbt quit. */ - lazy val versionNumber:String ={ + lazy val versionNumber: String ={ def getTimeString: String = { import java.util.Calendar; import java.text.SimpleDateFormat; @@ -66,20 +66,20 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj * not know what the main project definition is, as it will find many classes that extends Project */ - lazy val locker=project(info.projectPath,"locker", new LockerLayer(_)) - lazy val quick=project(info.projectPath,"quick",new QuickLayer(_,locker)) - lazy val strap=project(info.projectPath,"strap", new StrapLayer(_, quick)) - lazy val libs=project(info.projectPath,"libs", new LibsBuilder(_)) + lazy val locker = project(info.projectPath,"locker", new LockerLayer(_)) + lazy val quick = project(info.projectPath,"quick", new QuickLayer(_, locker)) + lazy val strap = project(info.projectPath,"strap", new StrapLayer(_, quick)) + lazy val libs = project(info.projectPath,"libs", new LibsBuilder(_)) /** * Definition of what is specific to the locker layer. It implements SimplePacker in order to * be able to create palo (packed locker) */ - class LockerLayer(info:ProjectInfo) extends BasicLayer(info,versionNumber,None) with Packer{ + class LockerLayer(info: ProjectInfo) extends BasicLayer(info, versionNumber, None) with Packer { - override lazy val nextLayer=Some(quick) + override lazy val nextLayer = Some(quick) lazy val instantiationCompilerJar = lib / compilerJarName lazy val instantiationLibraryJar = lib / libraryJarName lazy val lockFile = layerOutput / "locker.lock" @@ -90,7 +90,7 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj * whether the layer is locked or not should call super.task instead */ override def task(action : => Option[String])= - super.task{ + super.task { if (lockFile.exists) { log.info(name +" is locked") None @@ -98,27 +98,27 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj else action } - def deleteLock = FileUtilities.clean(lockFile,log) + def deleteLock = FileUtilities.clean(lockFile, log) def createLock = { log.info("locking "+name) - FileUtilities.touch(lockFile,log) + FileUtilities.touch(lockFile, log) } /** * Task for locking locker */ - lazy val lock = super.task{ + lazy val lock = super.task { createLock } /** * Task for unlocking locker */ - lazy val unlock = super.task{ + lazy val unlock = super.task { deleteLock } - lazy val newLocker = super.task{ + lazy val newLocker = super.task { createNewLocker } def createNewLocker = { @@ -133,18 +133,18 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj */ override lazy val finishLayer = lock.dependsOn(build) - override lazy val pack = super.task{packF}.dependsOn(finishLayer) + override lazy val pack = super.task {packF}.dependsOn(finishLayer) - override lazy val packingDestination:Path = outputRootPath /"palo" + override lazy val packingDestination: Path = outputRootPath /"palo" override lazy val libraryWS = { - new WrapperStep(libraryConfig::Nil) with WrapperPackaging{ + new WrapperStep(libraryConfig :: Nil) with WrapperPackaging { lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName, jarContent) } } override val minimalCompilation = true - override lazy val pluginsWS:WrapperStep = new WrapperStep(Nil) + override lazy val pluginsWS: WrapperStep = new WrapperStep(Nil) override lazy val toolsWS = new WrapperStep(Nil) } @@ -153,105 +153,98 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj * Definition of what is specific to the quick layer. It implements Packer in order to create pack, ScalaTools * for creating the binaries and Scaladoc to generate the documentation */ - class QuickLayer(info:ProjectInfo, previous:BasicLayer) extends BasicLayer(info,versionNumber,Some(previous)) with PartestRunner - with Packer with ScalaTools with Scaladoc{ + class QuickLayer(info: ProjectInfo, previous: BasicLayer) extends BasicLayer(info, versionNumber, Some(previous)) with PartestRunner + with Packer with ScalaTools with Scaladoc { - override lazy val nextLayer=Some(strap) + override lazy val nextLayer = Some(strap) lazy val instantiationCompilerJar = previous.compilerOutput lazy val instantiationLibraryJar = previous.libraryOutput - override lazy val packingDestination:Path = outputRootPath/ "pack" + override lazy val packingDestination: Path = outputRootPath/ "pack" - override def libraryToCopy = jlineJar::Nil - override def compilerAdditionalJars = msilJar::fjbgJar::Nil - override def libraryAdditionalJars = forkJoinJar::Nil + override def libraryToCopy = jlineJar :: Nil + override def compilerAdditionalJars = msilJar :: fjbgJar :: Nil + override def libraryAdditionalJars = forkJoinJar :: Nil - override def cleaningList = packedStarrOutput::super.cleaningList + override def cleaningList = packedStarrOutput :: super.cleaningList - override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil) with Packaging{ + override lazy val libraryWS = new WrapperStep(libraryConfig :: actorsConfig :: dbcConfig :: swingConfig :: Nil) with Packaging { def jarContent = List(libraryConfig , actorsConfig, continuationLibraryConfig).map(_.outputDirectory ##) - lazy val starrJarContent=List(libraryConfig , actorsConfig,dbcConfig,swingConfig, continuationLibraryConfig).map(_.outputDirectory ##) - lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName,jarContent,libraryAdditionalJars) - lazy val starrPackagingConfig = new PackagingConfiguration(packedStarrOutput/libraryJarName,starrJarContent) + lazy val starrJarContent = List(libraryConfig , actorsConfig, dbcConfig, swingConfig, continuationLibraryConfig).map(_.outputDirectory ##) + lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName, jarContent, libraryAdditionalJars) + lazy val starrPackagingConfig = new PackagingConfiguration(packedStarrOutput/libraryJarName, starrJarContent) } - override lazy val toolsWS = new WrapperStep(scalacheckConfig::scalapConfig::partestConfig::Nil) + override lazy val toolsWS = new WrapperStep(scalacheckConfig :: scalapConfig :: partestConfig :: Nil) // An additional task for building only the library of quick // Used for compiling msil - lazy val compileLibraryOnly = task{ + lazy val compileLibraryOnly = task { compile(libraryConfig, cleanCompilation _) } - lazy val externalCompileLibraryOnly = task{ - val runner = new ExternalTaskRunner(projectRoot,this.name,compileLibraryOnly.name,"Error during external compilation", log) + lazy val externalCompileLibraryOnly = task { + val runner = new ExternalTaskRunner(projectRoot, this.name, compileLibraryOnly.name, "Error during external compilation", log) runner.runTask }.dependsOn(startLayer) - - def createNewStarrJar:Option[String]={ + def createNewStarrJar: Option[String] = { import Packer._ - createJar(libraryWS.starrPackagingConfig,log) orElse - createJar(compilerConfig.starrPackagingConfig,log) + createJar(libraryWS.starrPackagingConfig, log) orElse + createJar(compilerConfig.starrPackagingConfig, log) } - lazy val pasta = task{ + lazy val pasta = task { createNewStarrJar }.dependsOn(build) - lazy val newStarr = task{ + lazy val newStarr = task { val files = (packedStarrOutput ##) * "*.jar" - FileUtilities.copy(files.get,lib,true,log) match{ - case Right(_) =>None - case Left(_) =>Some("Error occured when copying the new starr to its destination") + FileUtilities.copy(files.get, lib, true, log) match { + case Right(_) => None + case Left(_) => Some("Error occured when copying the new starr to its destination") } }.dependsOn(pasta) - - - - /* * Defining here the creation of the binaries for quick and pack */ - private lazy val quickBinClasspath = libraryOutput::actorsOutput::dbcOutput::swingOutput::compilerOutput::scalapOutput::forkJoinJar::fjbgJar::msilJar::jlineJar::Nil + private lazy val quickBinClasspath = libraryOutput :: actorsOutput :: dbcOutput :: swingOutput :: compilerOutput :: scalapOutput :: forkJoinJar :: fjbgJar :: msilJar :: jlineJar :: Nil private lazy val packBinClasspath = Nil lazy val binQuick = tools(layerOutput / "bin", quickBinClasspath).dependsOn(finishLayer) lazy val binPack = tools(packingDestination / "bin", packBinClasspath).dependsOn(pack) - - } /** * Definition of what is specific to the strap layer */ - class StrapLayer(info:ProjectInfo, previous:BasicLayer) extends BasicLayer(info,versionNumber,Some(previous)) { + class StrapLayer(info: ProjectInfo, previous: BasicLayer) extends BasicLayer(info, versionNumber, Some(previous)) { lazy val instantiationCompilerJar = previous.compilerOutput lazy val instantiationLibraryJar = previous.libraryOutput private val quick = previous - override lazy val libraryWS = new WrapperStep(libraryConfig::actorsConfig::dbcConfig::swingConfig::Nil) with WrapperPackaging{ - lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName,Set()) + override lazy val libraryWS = new WrapperStep(libraryConfig :: actorsConfig :: dbcConfig :: swingConfig :: Nil) with WrapperPackaging { + lazy val packagingConfig = new PackagingConfiguration(libsDestination/libraryJarName, Set()) } - override lazy val toolsWS= new WrapperStep(scalacheckConfig::scalapConfig::partestConfig::Nil) + override lazy val toolsWS = new WrapperStep(scalacheckConfig :: scalapConfig :: partestConfig :: Nil) def compare = { import PathConfig.classes - def filter(path:Path)= path.descendentsExcept(AllPassFilter, HiddenFileFilter || "*.properties") - Comparator.compare(quick.pathLayout.outputDir/classes ##,this.pathLayout.outputDir/classes ##, filter _ ,log) + def filter(path: Path)= path.descendentsExcept(AllPassFilter, HiddenFileFilter || "*.properties") + Comparator.compare(quick.pathLayout.outputDir/classes ##, this.pathLayout.outputDir/classes ##, filter _ , log) } - lazy val stabilityTest=task{ - log.warn("Stability test must be runned on a clean build in order to yield correct results.") + lazy val stabilityTest = task { + log.warn("Stability test must be run on a clean build in order to yield correct results.") compare }.dependsOn(finishLayer) @@ -260,80 +253,80 @@ class ScalaSBTBuilder(val info: ProjectInfo) extends Project with ReflectiveProj /** - * An additional subproject used to build new version of forkjoin,fjbg and msil + * An additional subproject used to build new version of forkjoin, fjbg and msil */ - class LibsBuilder(val info:ProjectInfo) extends ScalaBuildProject with ReflectiveProject with Compilation with BuildInfoEnvironment { + class LibsBuilder(val info: ProjectInfo) extends ScalaBuildProject with ReflectiveProject with Compilation with BuildInfoEnvironment { override def dependencies = info.dependencies - override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java"||AdditionalResources.basicFilter) // Support of triggered execution at project level + override def watchPaths = info.projectPath / "src" ** ("*.scala" || "*.java" ||AdditionalResources.basicFilter) // Support of triggered execution at project level - def buildInfoEnvironmentLocation:Path=outputRootPath / ("build-"+name+".properties") + def buildInfoEnvironmentLocation: Path = outputRootPath / ("build-"+name+".properties") - def instantiationCompilerJar:Path=locker.compilerOutput - def instantiationLibraryJar:Path=locker.libraryOutput + def instantiationCompilerJar: Path = locker.compilerOutput + def instantiationLibraryJar: Path = locker.libraryOutput def libsDestination = layerOutput - lazy val checkJavaVersion = task{ + lazy val checkJavaVersion = task { val version = System.getProperty("java.version") - log.debug("java.version="+version) + log.debug("java.version ="+version) val required = "1.6" if (version.startsWith(required)) None else Some("Incompatible java version : required "+required) } - private def simpleBuild(step:CompilationStep with Packaging)=task{ + private def simpleBuild(step: CompilationStep with Packaging)= task { import Packer._ - compile(step) orElse createJar(step,log) + compile(step) orElse createJar(step, log) }.dependsOn(locker.finishLayer) - private def copyJar(step:CompilationStep with Packaging, name:String) = task { - FileUtilities.copyFile(step.packagingConfig.jarDestination,lib/name,log) + private def copyJar(step: CompilationStep with Packaging, name: String) = task { + FileUtilities.copyFile(step.packagingConfig.jarDestination, lib/name, log) } - lazy val newForkjoin = copyJar(forkJoinConfig,forkjoinJarName).dependsOn(buildForkjoin) - lazy val buildForkjoin= simpleBuild(forkJoinConfig).dependsOn(checkJavaVersion) + lazy val newForkjoin = copyJar(forkJoinConfig, forkjoinJarName).dependsOn(buildForkjoin) + lazy val buildForkjoin = simpleBuild(forkJoinConfig).dependsOn(checkJavaVersion) lazy val newFjbg = copyJar(fjbgConfig, fjbgJarName).dependsOn(buildFjbg) lazy val buildFjbg = simpleBuild(fjbgConfig) - lazy val newMsil = copyJar(msilConfig,msilJarName).dependsOn(buildMsil) + lazy val newMsil = copyJar(msilConfig, msilJarName).dependsOn(buildMsil) // TODO As msil contains scala files, maybe needed compile it with an ExternalSBTRunner lazy val buildMsil = simpleBuild(msilConfig).dependsOn(quick.externalCompileLibraryOnly) - lazy val forkJoinConfig = new CompilationStep("forkjoin",pathLayout,log) with Packaging{ + lazy val forkJoinConfig = new CompilationStep("forkjoin", pathLayout, log) with Packaging { def label = "new forkjoin library" override def sources: PathFinder = sourceRoots.descendentsExcept("*.java", ".svn") def dependencies = Seq() def options = Seq() override def javaOptions = Seq("-target","1.5","-source","1.5","-g") - lazy val packagingConfig = new PackagingConfiguration(libsDestination/forkjoinJarName,List(outputDirectory ##)) + lazy val packagingConfig = new PackagingConfiguration(libsDestination/forkjoinJarName, List(outputDirectory ##)) } - lazy val fjbgConfig = new CompilationStep("fjbg",pathLayout,log) with Packaging{ + lazy val fjbgConfig = new CompilationStep("fjbg", pathLayout, log) with Packaging { def label = "new fjbg library" override def sources: PathFinder = sourceRoots.descendentsExcept("*.java", ".svn") def dependencies = Seq() def options = Seq() override def javaOptions = Seq("-target","1.5","-source","1.4","-g") - lazy val packagingConfig = new PackagingConfiguration(libsDestination/fjbgJarName,List(outputDirectory ##)) + lazy val packagingConfig = new PackagingConfiguration(libsDestination/fjbgJarName, List(outputDirectory ##)) } - lazy val msilConfig = new CompilationStep("msil",pathLayout,log) with Packaging{ + lazy val msilConfig = new CompilationStep("msil", pathLayout, log) with Packaging { def label = "new msil library" override def sources: PathFinder = sourceRoots.descendentsExcept("*.java"|"*.scala", ".svn"|"tests") def dependencies = Seq() override def classpath = super.classpath +++ quick.libraryOutput def options = Seq() override def javaOptions = Seq("-target","1.5","-source","1.4","-g") - lazy val packagingConfig = new PackagingConfiguration(libsDestination/msilJarName,List(outputDirectory ##)) + lazy val packagingConfig = new PackagingConfiguration(libsDestination/msilJarName, List(outputDirectory ##)) } - def cleaningList=layerOutput::layerEnvironment.envBackingPath::Nil + def cleaningList = layerOutput :: layerEnvironment.envBackingPath :: Nil - def cleanFiles = FileUtilities.clean(cleaningList,true,log) + def cleanFiles = FileUtilities.clean(cleaningList, true, log) - lazy val clean:Task = task{cleanFiles}// We use super.task, so cleaning is done in every case, even when locked + lazy val clean: Task = task {cleanFiles}// We use super.task, so cleaning is done in every case, even when locked } } diff --git a/project/build/ScalaTools.scala b/project/build/ScalaTools.scala index a182498467..9148177a96 100644 --- a/project/build/ScalaTools.scala +++ b/project/build/ScalaTools.scala @@ -7,8 +7,8 @@ import scala.io._ * Based on scala.tools.ant.ScalaTool * @author Grégory Moix (for the sbt adaptation) */ -trait ScalaTools{ - self:BasicLayer => +trait ScalaTools { + self: BasicLayer => lazy val templatesLocation = compilerConfig.srcDir/ "scala" / "tools" / "ant" / "templates" lazy val unixTemplate = templatesLocation / "tool-unix.tmpl" @@ -18,7 +18,7 @@ trait ScalaTools{ // XXX encoding and generalize private def getResourceAsCharStream(resource: Path): Stream[Char] = { val stream = new FileInputStream(resource.asFile) - def streamReader():Stream[Char]= stream.read match{ + def streamReader(): Stream[Char] = stream.read match { case -1 => Stream.empty case value => Stream.cons(value.asInstanceOf[Char], streamReader()) @@ -80,7 +80,7 @@ trait ScalaTools{ builder.toString } - private def writeFile(file: File, content: String, makeExecutable:Boolean):Option[String] = + private def writeFile(file: File, content: String, makeExecutable: Boolean): Option[String] = if (file.exists() && !file.canWrite()) Some("File " + file + " is not writable") else { @@ -93,12 +93,12 @@ trait ScalaTools{ /** Gets the value of the classpath attribute in a Scala-friendly form. * @return The class path as a list of files. */ - private def getUnixclasspath(classpath:List[String]): String = + private def getUnixclasspath(classpath: List[String]): String = transposeVariableMarkup(classpath.mkString("", ":", "").replace('\\', '/'), "${", "}") /** Gets the value of the classpath attribute in a Scala-friendly form. * @return The class path as a list of files. */ - private def getWinclasspath(classpath:List[String]): String = + private def getWinclasspath(classpath: List[String]): String = transposeVariableMarkup(classpath.mkString("", ";", "").replace('/', '\\'), "%", "%") /** Performs the tool creation of a tool with for a given os @@ -111,8 +111,8 @@ trait ScalaTools{ * @param template * @param classpathFormater */ - private def tool(template:Path,classpathFormater: List[String]=>String, file:Path,mainClass:String, - properties:String,javaFlags:String,toolFlags:String,classPath:List[Path],makeExecutable:Boolean):Option[String] = { + private def tool(template: Path, classpathFormater: List[String] => String, file: Path, mainClass: String, + properties: String, javaFlags: String, toolFlags: String, classPath: List[Path], makeExecutable: Boolean): Option[String] = { val patches = Map ( ("class", mainClass), ("properties", properties), @@ -121,18 +121,18 @@ trait ScalaTools{ ("classpath", classpathFormater(classPath.map(_.absolutePath))) ) - val result = readAndPatchResource(template,patches) - writeFile(file.asFile,result,makeExecutable) + val result = readAndPatchResource(template, patches) + writeFile(file.asFile, result, makeExecutable) } - private def generateTool(config:ToolConfiguration):Option[String] = - generateTool(config.toolName,config.destination,config.mainClass,config.properties,config.javaFlags,config.toolFlags,config.classPath) + private def generateTool(config: ToolConfiguration): Option[String] = + generateTool(config.toolName, config.destination, config.mainClass, config.properties, config.javaFlags, config.toolFlags, config.classPath) - private def generateTool(toolName:String,destination:Path,mainClass:String, properties:String,javaFlags:String,toolFlags:String,classPath:List[Path]):Option[String] ={ + private def generateTool(toolName: String, destination: Path, mainClass: String, properties: String, javaFlags: String, toolFlags: String, classPath: List[Path]): Option[String] ={ val unixFile = destination / toolName val winFile = destination /(toolName + ".bat") - tool(unixTemplate,getUnixclasspath,unixFile,mainClass, properties,javaFlags,toolFlags,classPath,true) orElse - tool(winTemplate,getWinclasspath,winFile,mainClass, properties,javaFlags,toolFlags,classPath,false) + tool(unixTemplate, getUnixclasspath, unixFile, mainClass, properties, javaFlags, toolFlags, classPath, true) orElse + tool(winTemplate, getWinclasspath, winFile, mainClass, properties, javaFlags, toolFlags, classPath, false) } @@ -144,7 +144,7 @@ trait ScalaTools{ /** * A class that holds the different parameters of a tool */ - class ToolConfiguration(val toolName:String, val destination:Path, val mainClass:String, val properties:String, val javaFlags:String,val toolFlags:String,val classPath:List[Path]) + class ToolConfiguration(val toolName: String, val destination: Path, val mainClass: String, val properties: String, val javaFlags: String, val toolFlags: String, val classPath: List[Path]) /** * Generate all tools @@ -152,7 +152,7 @@ trait ScalaTools{ * @param classpath Should be specified when you want to use a specific classpath, could be Nil if you want * to make the bin use what is in the lib folder of the distribution. */ - def tools(destination:Path,classpath:List[Path]) = task{ + def tools(destination: Path, classpath: List[Path]) = task { val scala = new ToolConfiguration("scala", destination, "scala.tools.nsc.MainGenericRunner", "",defaultJavaFlags, "", classpath) val scalac = new ToolConfiguration("scalac", destination, "scala.tools.nsc.Main", "",defaultJavaFlags, "", classpath) val scaladoc = new ToolConfiguration("scaladoc",destination,"scala.tools.nsc.ScalaDoc", "",defaultJavaFlags,"", classpath) @@ -160,17 +160,17 @@ trait ScalaTools{ val scalap = new ToolConfiguration("scalap",destination, "scala.tools.scalap.Main", "",defaultJavaFlags, "", classpath) - val toolList = scala ::scalac::scaladoc::fsc::scalap::Nil + val toolList = scala :: scalac :: scaladoc :: fsc :: scalap :: Nil - def process(list:List[ToolConfiguration]):Option[String] = list match{ - case x::xs => { + def process(list: List[ToolConfiguration]): Option[String] = list match { + case x :: xs => { log.debug("Generating "+x.toolName+" bin") generateTool(x) orElse process(xs) } case Nil => None } - FileUtilities.createDirectory(destination,log) + FileUtilities.createDirectory(destination, log) process(toolList) } diff --git a/project/build/Scaladoc.scala b/project/build/Scaladoc.scala index fc64e43c17..7f2580f5b2 100644 --- a/project/build/Scaladoc.scala +++ b/project/build/Scaladoc.scala @@ -1,13 +1,13 @@ import sbt._ import xsbt.AnalyzingCompiler -trait Scaladoc{ - self:BasicLayer with Packer => +trait Scaladoc { + self: BasicLayer with Packer => lazy val documentationDestination = outputRootPath / "scaladoc" lazy val libraryDocumentationDestination = documentationDestination / "library" lazy val compilerDocumentationDestination = documentationDestination / "compiler" - lazy val libraryDoc= { + lazy val libraryDoc = { val reflect = librarySrcDir / "scala" / "reflect" val runtime = librarySrcDir / "scala" / "runtime" @@ -34,15 +34,15 @@ trait Scaladoc{ (antJar +++ jlineJar +++ msilJar +++ fjbgJar +++ forkJoinJar +++ outputLibraryJar +++ outputCompilerJar +++ outputPartestJar +++ outputScalapJar ).get } - lazy val scaladoc = task{ - val externalSbt = new ExternalTaskRunner(projectRoot,this.name,generateScaladoc.name,"Error generating the scaladoc",log) + lazy val scaladoc = task { + val externalSbt = new ExternalTaskRunner(projectRoot, this.name, generateScaladoc.name, "Error generating the scaladoc", log) externalSbt.runTask }.dependsOn(pack) - lazy val generateScaladoc=task{ + lazy val generateScaladoc = task { instanceScope[Option[String]]{ scala => - lazy val compiler = new AnalyzingCompiler(scala,componentManager,xsbt.ClasspathOptions.manual,log) - val docGenerator = new sbt.Scaladoc(50,compiler) + lazy val compiler = new AnalyzingCompiler(scala, componentManager, xsbt.ClasspathOptions.manual, log) + val docGenerator = new sbt.Scaladoc(50, compiler) docGenerator("Scala "+ versionNumber+" API", libraryDoc.get, classpath, libraryDocumentationDestination, Seq(), log) orElse docGenerator("Scala Compiler"+ versionNumber+" API", compilerDoc.get, classpath, compilerDocumentationDestination, Seq(), log) } -- cgit v1.2.3