cleanup, small fixes

This commit is contained in:
Mark Harrah 2010-11-24 14:08:20 -05:00
parent 4fd7611074
commit ccf0508ce6
5 changed files with 21 additions and 18 deletions

View File

@ -4,7 +4,7 @@
package sbt
package inc
import java.io.{File, InputStream, IOException}
import java.io.{File, IOException}
import sbinary._
import Operations.{read, write}
import DefaultProtocol._
@ -14,19 +14,13 @@ object FileBasedStore
{
def apply(file: File)(implicit analysisF: Format[Analysis], setupF: Format[CompileSetup]): AnalysisStore = new AnalysisStore {
def set(analysis: Analysis, setup: CompileSetup): Unit =
Using.fileOutputStream()(file) { fout =>
Using.gzipOutputStream(fout) { outg =>
Using.bufferedOutputStream(outg) { out =>
IO.gzipFileOut(file) { out =>
write[(Analysis, CompileSetup)](out, (analysis, setup) )
}}}
}
def get(): Option[(Analysis, CompileSetup)] =
try { Some(getUncaught()) } catch { case io: IOException => None }
def getUncaught(): (Analysis, CompileSetup) =
Using.fileInputStream(file) { fin =>
Using.gzipInputStream(fin) { ing =>
Using.bufferedInputStream(ing) { in =>
read[(Analysis, CompileSetup)]( in )
}}}
IO.gzipFileIn(file)( in => read[(Analysis, CompileSetup)](in) )
}
}

View File

@ -183,7 +183,7 @@ object ClasspathProject
analyzed(i.config.classesDirectory, analysis)
}
def makeProducts(compile: Task[Analysis], inputs: Task[Compile.Inputs], name: String, prefix: String) =
def makeProducts(compile: Task[Analysis], inputs: Task[Compile.Inputs], name: String, prefix: String): Task[Seq[Attributed[File]]] =
{
def mkName(postfix: String) = name + "/" + prefix + postfix
analyzed(compile, inputs) named(mkName("analyzed")) map { _ :: Nil } named(mkName("products"))
@ -265,7 +265,7 @@ object ClasspathProject
def missingMapping(from: String, to: String, conf: String) =
error("No configuration mapping defined from '" + from + "' to '" + to + "' for '" + conf + "'")
def missingConfiguration(in: String, conf: String) =
error("Configuration '" + conf + "' not defined in '" + in)
error("Configuration '" + conf + "' not defined in '" + in + "'")
def allConfigs(dep: Project, conf: String): Seq[String] =
dep match {
case cp: ClasspathProject => Dag.topologicalSort(configuration(cp, conf))(_.extendsConfigs).map(_.name)

View File

@ -93,7 +93,7 @@ ProjectCommand +
def DefaultsDetailed = "Registers default built-in commands"
def ReloadCommand = "reload"
def ReloadBrief = (ReloadCommand, "Reloads the session and continues to execute the remaining commands.")
def ReloadBrief = (ReloadCommand, "Reloads the session and then executes the remaining commands.")
def ReloadDetailed =
ReloadCommand + """
This command is equivalent to exiting, restarting, and running the
@ -160,7 +160,6 @@ DiscoverSyntax + """
CompileSyntax + """
Incrementally compiles Scala and Java sources.
Java source support is limited at this time.
<paths> are explicit paths separated by the platform path separator.

View File

@ -56,15 +56,15 @@ final class Scaladoc(maximumErrors: Int, compiler: AnalyzingCompiler)
{
log.info(actionStartMessage(label))
if(sources.isEmpty)
log.info(actionNothingToDoMessage)
log.info(ActionNothingToDoMessage)
else
{
IO.createDirectory(outputDirectory)
compiler.doc(sources, classpath, outputDirectory, options, maximumErrors, log)
log.info(actionSuccessfulMessage)
log.info(ActionSuccessfulMessage)
}
}
def actionStartMessage(label: String) = "Generating API documentation for " + label + " sources..."
val actionNothingToDoMessage = "No sources specified."
val actionSuccessfulMessage = "API documentation generation successful."
val ActionNothingToDoMessage = "No sources specified."
val ActionSuccessfulMessage = "API documentation generation successful."
}

View File

@ -569,4 +569,14 @@ object IO
delete(a)
}
}
def gzipFileOut[T](file: File)(f: OutputStream => T): T =
Using.fileOutputStream()(file) { fout =>
Using.gzipOutputStream(fout) { outg =>
Using.bufferedOutputStream(outg)(f) }}
def gzipFileIn[T](file: File)(f: InputStream => T): T =
Using.fileInputStream(file) { fin =>
Using.gzipInputStream(fin) { ing =>
Using.bufferedInputStream(ing)(f) }}
}