build sxr, api docs and use sbinary 0.4.0

This commit is contained in:
Mark Harrah 2011-05-17 20:09:20 -04:00
parent 523553b9ca
commit 06ec88af3d
17 changed files with 58 additions and 51 deletions

16
cache/Cache.scala vendored
View File

@ -3,7 +3,7 @@
*/
package sbt
import sbinary.{CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, Output}
import sbinary.{CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, Output => Out}
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream}
import java.net.{URI, URL}
import Types.:+:
@ -45,7 +45,7 @@ object Cache extends CacheImplicits
println(label + ".read: " + v)
v
}
def write(to: Output, v: Internal)
def write(to: Out, v: Internal)
{
println(label + ".write: " + v)
c.write(to, v)
@ -79,7 +79,7 @@ trait BasicCacheImplicits
val isDefined = BooleanFormat.reads(from)
if(isDefined) Some(t.read(from)) else None
}
def write(to: Output, j: Internal): Unit =
def write(to: Out, j: Internal): Unit =
{
BooleanFormat.writes(to, j.isDefined)
j foreach { x => t.write(to, x) }
@ -129,7 +129,7 @@ trait BasicCacheImplicits
if(left <= 0) acc.reverse else next(left - 1, t.read(from) :: acc)
next(size, Nil)
}
def write(to: Output, vs: Internal)
def write(to: Out, vs: Internal)
{
val size = vs.length
IntFormat.writes(to, size)
@ -157,7 +157,7 @@ trait BasicCacheImplicits
type Internal = jCache.Internal
def convert(i: I) = jCache.convert(f(i))
def read(from: Input) = jCache.read(from)
def write(to: Output, j: Internal) = jCache.write(to, j)
def write(to: Out, j: Internal) = jCache.write(to, j)
def equiv = jCache.equiv
}
@ -180,7 +180,7 @@ trait HListCacheImplicits
val t = tail.read(from)
(h, t)
}
def write(to: Output, j: Internal)
def write(to: Out, j: Internal)
{
head.write(to, j._1)
tail.write(to, j._2)
@ -202,7 +202,7 @@ trait HListCacheImplicits
val t = tail.reads(from)
HCons(h, t)
}
def writes(to: Output, hc: H :+: T)
def writes(to: Out, hc: H :+: T)
{
head.writes(to, hc.head)
tail.writes(to, hc.tail)
@ -225,7 +225,7 @@ trait UnionImplicits
val value = cache.read(in)
new Found[cache.Internal](cache, clazz, value, index)
}
def write(to: Output, i: Internal)
def write(to: Out, i: Internal)
{
def write0[I](f: Found[I])
{

View File

@ -4,9 +4,8 @@
package sbt
import Types.:+:
import sbinary.{DefaultProtocol, Format, Input, JavaIO, Output}
import sbinary.{DefaultProtocol, Format, Input, Output => Out}
import DefaultProtocol.ByteFormat
import JavaIO._
import java.io.{File, InputStream, OutputStream}
trait InputCache[I]
@ -14,7 +13,7 @@ trait InputCache[I]
type Internal
def convert(i: I): Internal
def read(from: Input): Internal
def write(to: Output, j: Internal): Unit
def write(to: Out, j: Internal): Unit
def equiv: Equiv[Internal]
}
object InputCache
@ -25,7 +24,7 @@ object InputCache
type Internal = I
def convert(i: I) = i
def read(from: Input): I = fmt.reads(from)
def write(to: Output, i: I) = fmt.writes(to, i)
def write(to: Out, i: I) = fmt.writes(to, i)
def equiv = eqv
}
}

View File

@ -5,7 +5,7 @@ package sbt
import java.io.File
import CacheIO.{fromFile, toFile}
import sbinary.{Format, JavaIO}
import sbinary.Format
import scala.reflect.Manifest
import scala.collection.mutable
import IO.{delete, read, write}
@ -29,8 +29,6 @@ object Tracked
def diffOutputs(cache: File, style: FilesInfo.Style): Difference =
Difference.outputs(cache, style)
import sbinary.JavaIO._
def lastOutput[I,O](cacheFile: File)(f: (I,Option[O]) => O)(implicit o: Format[O], mf: Manifest[Format[O]]): I => O = in =>
{
val previous: Option[O] = fromFile[O](cacheFile)
@ -112,7 +110,7 @@ class Changed[O](val cacheFile: File)(implicit equiv: Equiv[O], format: Format[O
ifChanged(value)
}
}
import JavaIO._
def update(value: O): Unit = Using.fileOutputStream(false)(cacheFile)(stream => format.writes(stream, value))
def uptodate(value: O): Boolean =
try {

View File

@ -30,7 +30,7 @@ final class Eval(optionsNoncp: Seq[String], classpath: Seq[File], mkReporter: Se
lazy val settings =
{
val s = new Settings(Console.println)
val s = new Settings(println)
val command = new CompilerCommand(options.toList, s)
s
}

View File

@ -12,7 +12,7 @@ package sbt
import java.util.EnumMap
import scala.collection.mutable
import LoggerReporter._
import Severity.{Error,Info,Warn}
import Severity.{Error,Info => SInfo,Warn}
object LoggerReporter
{
@ -56,7 +56,7 @@ class LoggerReporter(maximumErrors: Int, log: Logger) extends xsbti.Reporter
def reset()
{
count.put(Warn, 0)
count.put(Info, 0)
count.put(SInfo, 0)
count.put(Error, 0)
positions.clear()
allProblems.clear()
@ -90,7 +90,7 @@ class LoggerReporter(maximumErrors: Int, log: Logger) extends xsbti.Reporter
{
case Error => log.error(m)
case Warn => log.warn(m)
case Info => log.info(m)
case SInfo => log.info(m)
})
}

View File

@ -8,7 +8,6 @@ package inc
import sbinary._
import Operations.{read, write}
import DefaultProtocol._
import JavaIO._
object FileBasedStore
{

View File

@ -9,7 +9,6 @@ package xsbt.api
import sbinary._
import DefaultProtocol._
import Operations.{read,write}
import JavaIO._
import java.io.File
import scala.collection.mutable

View File

@ -7,7 +7,8 @@ import Artifact.{defaultExtension, defaultType}
import java.io.File
import java.util.concurrent.Callable
import java.util.{Collection, Collections}
import java.util.{Collection, Collections => CS}
import CS.singleton
import org.apache.ivy.{core, plugins, util, Ivy}
import core.IvyPatternHelper
@ -465,7 +466,7 @@ private object IvySbt
if(dynamic) null else {
try {
val l = getStrategy.findLatest(toArtifactInfo(conflicts), null).asInstanceOf[{def getNode(): IvyNode}]
if(l eq null) conflicts else Collections.singleton(l.getNode)
if(l eq null) conflicts else singleton(l.getNode)
}
catch { case e: LatestConflictManager.NoConflictResolvedYetException => null }
}

View File

@ -4,7 +4,7 @@
package sbt
import java.io.File
import scala.xml.{Node,NodeSeq}
import scala.xml.{Node => XNode,NodeSeq}
import org.apache.ivy.{core, plugins, Ivy}
import core.cache.DefaultRepositoryCacheManager
@ -26,7 +26,7 @@ final class PublishConfiguration(val ivyFile: Option[File], val resolverName: St
final class UpdateConfiguration(val retrieve: Option[RetrieveConfiguration], val missingOk: Boolean, val logging: UpdateLogging.Value)
final class RetrieveConfiguration(val retrieveDirectory: File, val outputPattern: String)
final case class MakePomConfiguration(file: File, configurations: Option[Iterable[Configuration]] = None, extra: NodeSeq = NodeSeq.Empty, process: Node => Node = n => n, filterRepositories: MavenRepository => Boolean = _ => true)
final case class MakePomConfiguration(file: File, configurations: Option[Iterable[Configuration]] = None, extra: NodeSeq = NodeSeq.Empty, process: XNode => XNode = n => n, filterRepositories: MavenRepository => Boolean = _ => true)
/** Configures logging during an 'update'. `level` determines the amount of other information logged.
* `Full` is the default and logs the most.

View File

@ -4,7 +4,7 @@
package sbt
import java.io.File
import scala.xml.{Node, NodeSeq}
import scala.xml.NodeSeq
final class IvyPaths(val baseDirectory: File, val ivyHome: Option[File])
{

View File

@ -3,7 +3,7 @@
*/
package sbt
import java.util.Collections
import java.util.Collections.emptyMap
import scala.collection.mutable.HashSet
import org.apache.ivy.{core, plugins}
@ -92,7 +92,7 @@ private object IvyScala
private def excludeRule(organization: String, name: String, configurationNames: Iterable[String]): ExcludeRule =
{
val artifact = new ArtifactId(ModuleId.newInstance(organization, name), "*", "jar", "*")
val rule = new DefaultExcludeRule(artifact, ExactPatternMatcher.INSTANCE, Collections.emptyMap[AnyRef,AnyRef])
val rule = new DefaultExcludeRule(artifact, ExactPatternMatcher.INSTANCE, emptyMap[AnyRef,AnyRef])
configurationNames.foreach(rule.addConfiguration)
rule
}

View File

@ -8,7 +8,7 @@
package sbt;
import java.io.{BufferedWriter, File, OutputStreamWriter, FileOutputStream}
import scala.xml.{Node, NodeSeq, PrettyPrinter, XML}
import scala.xml.{Node => XNode, NodeSeq, PrettyPrinter, XML}
import org.apache.ivy.{core, plugins, Ivy}
import core.settings.IvySettings
@ -20,9 +20,9 @@ import plugins.resolver.{ChainResolver, DependencyResolver, IBiblioResolver}
class MakePom
{
def encoding = "UTF-8"
def write(ivy: Ivy, module: ModuleDescriptor, configurations: Option[Iterable[Configuration]], extra: NodeSeq, process: Node => Node, filterRepositories: MavenRepository => Boolean, output: File): Unit =
def write(ivy: Ivy, module: ModuleDescriptor, configurations: Option[Iterable[Configuration]], extra: NodeSeq, process: XNode => XNode, filterRepositories: MavenRepository => Boolean, output: File): Unit =
write(process(toPom(ivy, module, configurations, extra, filterRepositories)), output)
def write(node: Node, output: File): Unit = write(toString(node), output)
def write(node: XNode, output: File): Unit = write(toString(node), output)
def write(xmlString: String, output: File)
{
output.getParentFile.mkdirs()
@ -36,8 +36,8 @@ class MakePom
finally { out.close() }
}
def toString(node: Node): String = new PrettyPrinter(1000, 4).format(node)
def toPom(ivy: Ivy, module: ModuleDescriptor, configurations: Option[Iterable[Configuration]], extra: NodeSeq, filterRepositories: MavenRepository => Boolean): Node =
def toString(node: XNode): String = new PrettyPrinter(1000, 4).format(node)
def toPom(ivy: Ivy, module: ModuleDescriptor, configurations: Option[Iterable[Configuration]], extra: NodeSeq, filterRepositories: MavenRepository => Boolean): XNode =
(<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
{ makeModuleID(module) }
@ -150,9 +150,9 @@ class MakePom
def toID(name: String) = checkID(name.filter(isValidIDCharacter).mkString, name)
def isValidIDCharacter(c: Char) = c.isLetterOrDigit
private def checkID(id: String, name: String) = if(id.isEmpty) error("Could not convert '" + name + "' to an ID") else id
def mavenRepository(repo: MavenRepository): Node =
def mavenRepository(repo: MavenRepository): XNode =
mavenRepository(toID(repo.name), repo.name, repo.root)
def mavenRepository(id: String, name: String, root: String): Node =
def mavenRepository(id: String, name: String, root: String): XNode =
<repository>
<id>{id}</id>
<name>{name}</name>

View File

@ -9,8 +9,7 @@ package sbt
import std.TaskExtra._
import Types.{:+:, idFun}
import sbinary.{Format, JavaIO, Operations}
import JavaIO._
import sbinary.{Format, Operations}
object TaskData
{

View File

@ -71,7 +71,6 @@ object Sync
import sbinary._
import Operations.{read, write}
import DefaultProtocol.{FileFormat => _, _}
import JavaIO._
import inc.AnalysisFormats._
def writeInfo[F <: FileInfo](file: File, relation: Relation[File, File], info: Map[File, F])(implicit infoFormat: Format[F]): Unit =

View File

@ -3,10 +3,10 @@ import sbt._
trait Sxr extends BasicScalaProject
{
val sxrConf = config("sxr") hide
val sxrDep = "org.scala-tools.sxr" %% "sxr" % "0.2.4" % sxrConf.name
val sxrDep = "org.scala-tools.sxr" %% "sxr" % "0.2.7" % sxrConf.name jar()
def deepSources: PathFinder
def deepBaseDirectories = Path.finder { topologicalSort.flatMap { case p: ScalaPaths => p.mainSourceRoots.getFiles } }
def deepBaseDirectories: PathFinder
def sxrBaseDirs = "-P:sxr:base-directory:" + deepBaseDirectories.absString
def sxrLocation = "-Xplugin:" + managedClasspath(sxrConf).absString
def sxrDirName = "browse"

View File

@ -83,7 +83,7 @@ class XSbt(info: ProjectInfo) extends ParentProject(info) with NoCrossPaths
interfaceSub, ioSub, ivySub, logSub, processSub, runSub, stdTaskSub, taskSub, trackingSub, testingSub)
// The main integration project for sbt. It brings all of the subsystems together, configures them, and provides for overriding conventions.
val mainSub = baseProject(mainPath, "Main", actionsSub, interfaceSub, ioSub, ivySub, launchInterfaceSub, logSub, processSub, runSub)
val mainSub = project(mainPath, "Main", new Main(_), actionsSub, interfaceSub, ioSub, ivySub, launchInterfaceSub, logSub, processSub, runSub)
// Strictly for bringing implicits and aliases from subsystems into the top-level sbt namespace through a single package object
// technically, we need a dependency on all of mainSub's dependencies, but we don't do that since this is strictly an integration project
// with the sole purpose of providing certain identifiers without qualification (with a package object)
@ -164,7 +164,7 @@ class XSbt(info: ProjectInfo) extends ParentProject(info) with NoCrossPaths
{
// these compilation options are useful for debugging caches and task composition
//override def compileOptions = super.compileOptions ++ List(Unchecked,ExplainTypes, CompileOption("-Xlog-implicits"))
val sbinary = "org.scala-tools.sbinary" % "sbinary_2.8.0" % "0.3.1"
val sbinary = "org.scala-tools.sbinary" %% "sbinary" % "0.4.0"
}
class Base(info: ProjectInfo) extends DefaultProject(info) with ManagedBase with Component with Licensed
{
@ -330,4 +330,16 @@ class XSbt(info: ProjectInfo) extends ParentProject(info) with NoCrossPaths
None
} dependsOn(publishLocal, scriptedSbtSub.compile, testCompile) }
}
class Main(info: ProjectInfo) extends Base(info) with Sxr
{
def concatPaths[T](s: Seq[T])(f: PartialFunction[T, PathFinder]): PathFinder =
{
def finder: T => PathFinder = (f orElse { case _ => Path.emptyPathFinder })
(Path.emptyPathFinder /: s) { _ +++ finder(_) }
}
def deepBaseDirectories = Path.finder { topologicalSort.flatMap { case p: ScalaPaths => p.mainSourceRoots.getFiles } }
def deepSources = concatPaths(mainSub.topologicalSort){ case p: ScalaPaths => p.mainSources }
// override def documentOptions = CompoundDocOption("-sourcepath", deepBaseDirectories.absString) :: LinkSource :: super.documentOptions.toList
lazy val sbtGenDoc = scaladocTask("sbt", deepSources, docPath, docClasspath, documentOptions) dependsOn(compile)
}
}

View File

@ -54,16 +54,17 @@ object ConsoleLogger
* This logger is not thread-safe.*/
class ConsoleLogger private[ConsoleLogger](val out: ConsoleOut, override val ansiCodesSupported: Boolean, val useColor: Boolean) extends BasicLogger
{
def messageColor(level: Level.Value) = Console.RESET
import scala.Console.{BLUE, GREEN, RED, RESET, YELLOW}
def messageColor(level: Level.Value) = RESET
def labelColor(level: Level.Value) =
level match
{
case Level.Error => Console.RED
case Level.Warn => Console.YELLOW
case _ => Console.RESET
case Level.Error => RED
case Level.Warn => YELLOW
case _ => RESET
}
def successLabelColor = Console.GREEN
def successMessageColor = Console.RESET
def successLabelColor = GREEN
def successMessageColor = RESET
override def success(message: => String)
{
if(successEnabled)
@ -81,7 +82,7 @@ class ConsoleLogger private[ConsoleLogger](val out: ConsoleOut, override val ans
if(atLevel(level))
log(labelColor(level), level.toString, messageColor(level), message)
}
private def reset(): Unit = setColor(Console.RESET)
private def reset(): Unit = setColor(RESET)
private def setColor(color: String)
{
@ -108,7 +109,7 @@ class ConsoleLogger private[ConsoleLogger](val out: ConsoleOut, override val ans
def logAll(events: Seq[LogEvent]) = out.lockObject.synchronized { events.foreach(log) }
def control(event: ControlEvent.Value, message: => String)
{ log(labelColor(Level.Info), Level.Info.toString, Console.BLUE, message) }
{ log(labelColor(Level.Info), Level.Info.toString, BLUE, message) }
}
sealed trait ConsoleOut
{