mirror of https://github.com/sbt/sbt.git
Set -> Seq for sources, classpaths
This commit is contained in:
parent
3b8aeddbfb
commit
f9a7a0a28e
|
|
@ -12,19 +12,23 @@ package xsbt
|
|||
class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: ComponentManager, val cp: ClasspathOptions, log: CompileLogger) extends NotNull
|
||||
{
|
||||
def this(scalaInstance: ScalaInstance, manager: ComponentManager, log: CompileLogger) = this(scalaInstance, manager, ClasspathOptions.auto, log)
|
||||
def apply(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String], callback: AnalysisCallback, maximumErrors: Int, log: CompileLogger)
|
||||
def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String], callback: AnalysisCallback, maximumErrors: Int, log: CompileLogger)
|
||||
{
|
||||
val arguments = (new CompilerArguments(scalaInstance, cp))(sources, classpath, outputDirectory, options)
|
||||
compile(arguments, callback, maximumErrors, log)
|
||||
}
|
||||
def compile(arguments: Seq[String], callback: AnalysisCallback, maximumErrors: Int, log: CompileLogger)
|
||||
{
|
||||
call("xsbt.CompilerInterface", log)(
|
||||
classOf[Array[String]], classOf[AnalysisCallback], classOf[Int], classOf[xLogger] ) (
|
||||
arguments.toArray[String] : Array[String], callback, maximumErrors: java.lang.Integer, log )
|
||||
}
|
||||
def doc(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String], maximumErrors: Int, log: CompileLogger): Unit =
|
||||
def doc(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String], maximumErrors: Int, log: CompileLogger): Unit =
|
||||
{
|
||||
val arguments = (new CompilerArguments(scalaInstance, cp))(sources, classpath, outputDirectory, options)
|
||||
call("xsbt.ScaladocInterface", log) (classOf[Array[String]], classOf[Int], classOf[xLogger]) (arguments.toArray[String] : Array[String], maximumErrors: java.lang.Integer, log)
|
||||
}
|
||||
def console(classpath: Set[File], options: Seq[String], initialCommands: String, log: CompileLogger): Unit =
|
||||
def console(classpath: Seq[File], options: Seq[String], initialCommands: String, log: CompileLogger): Unit =
|
||||
{
|
||||
val arguments = new CompilerArguments(scalaInstance, cp)
|
||||
val classpathString = CompilerArguments.absString(arguments.finishClasspath(classpath))
|
||||
|
|
|
|||
|
|
@ -10,19 +10,18 @@ package xsbt
|
|||
* this would lead to compiling against the wrong library jar.*/
|
||||
class CompilerArguments(scalaInstance: ScalaInstance, cp: ClasspathOptions) extends NotNull
|
||||
{
|
||||
def apply(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String]): Seq[String] =
|
||||
def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String]): Seq[String] =
|
||||
{
|
||||
checkScalaHomeUnset()
|
||||
val bootClasspathOption = if(cp.autoBoot) Seq("-bootclasspath", createBootClasspath) else Nil
|
||||
val cpWithCompiler = finishClasspath(classpath)
|
||||
val classpathOption = Seq("-cp", absString(cpWithCompiler) )
|
||||
val outputOption = Seq("-d", outputDirectory.getAbsolutePath)
|
||||
options ++ outputOption ++ bootClasspathOption ++ classpathOption ++ abs(sources)
|
||||
}
|
||||
def finishClasspath(classpath: Set[File]): Set[File] =
|
||||
def finishClasspath(classpath: Seq[File]): Seq[File] =
|
||||
classpath ++ include(cp.compiler, scalaInstance.compilerJar) ++ include(cp.extra, scalaInstance.extraJars : _*)
|
||||
private def include(flag: Boolean, jars: File*) = if(flag) jars else Nil
|
||||
protected def abs(files: Set[File]) = files.map(_.getAbsolutePath).toList.sortWith(_ < _)
|
||||
protected def abs(files: Seq[File]) = files.map(_.getAbsolutePath).sortWith(_ < _)
|
||||
protected def checkScalaHomeUnset()
|
||||
{
|
||||
val scalaHome = System.getProperty("scala.home")
|
||||
|
|
@ -35,6 +34,8 @@ class CompilerArguments(scalaInstance: ScalaInstance, cp: ClasspathOptions) exte
|
|||
val newBootPrefix = if(originalBoot.isEmpty) "" else originalBoot + File.pathSeparator
|
||||
newBootPrefix + scalaInstance.libraryJar.getAbsolutePath
|
||||
}
|
||||
def bootClasspathOption = if(cp.autoBoot) Seq("-bootclasspath", createBootClasspath) else Nil
|
||||
def bootClasspath = if(cp.autoBoot) sbt.IO.pathSplit(createBootClasspath).map(new File(_)).toSeq else Nil
|
||||
}
|
||||
class ClasspathOptions(val autoBoot: Boolean, val compiler: Boolean, val extra: Boolean) extends NotNull
|
||||
object ClasspathOptions
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager)
|
|||
val start = System.currentTimeMillis
|
||||
try
|
||||
{
|
||||
compiler(Set() ++ sourceFiles, Set() ++ xsbtiJars ++ sourceJars, outputDirectory, "-nowarn" :: Nil)
|
||||
compiler(sourceFiles.toSeq, xsbtiJars.toSeq ++ sourceJars, outputDirectory, "-nowarn" :: Nil)
|
||||
manager.log.info(" Compilation completed in " + (System.currentTimeMillis - start) / 1000.0 + " s")
|
||||
}
|
||||
catch { case e: xsbti.CompileFailed => throw new CompileFailed(e.arguments, "Error compiling sbt component '" + id + "'") }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package xsbt
|
|||
* the scala-library.jar from `scalaInstance` is put on bootclasspath and the scala-compiler jar goes on the classpath.*/
|
||||
class RawCompiler(val scalaInstance: ScalaInstance, cp: ClasspathOptions, log: CompileLogger)
|
||||
{
|
||||
def apply(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String])
|
||||
def apply(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String])
|
||||
{
|
||||
// reflection is required for binary compatibility
|
||||
// The following import ensures there is a compile error if the identifiers change,
|
||||
|
|
|
|||
Loading…
Reference in New Issue