From 06ec88af3df5c3bd5ed4a454d6559674a078b077 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 17 May 2011 20:09:20 -0400 Subject: [PATCH] build sxr, api docs and use sbinary 0.4.0 --- cache/Cache.scala | 16 ++++++++-------- cache/SeparatedCache.scala | 7 +++---- cache/tracking/Tracked.scala | 6 ++---- compile/Eval.scala | 2 +- compile/LoggerReporter.scala | 6 +++--- compile/persist/FileBasedStore.scala | 1 - compile/persist/SourceFormat.scala | 1 - ivy/Ivy.scala | 5 +++-- ivy/IvyActions.scala | 4 ++-- ivy/IvyConfigurations.scala | 2 +- ivy/IvyScala.scala | 4 ++-- ivy/MakePom.scala | 14 +++++++------- main/TaskData.scala | 3 +-- main/actions/Sync.scala | 1 - project/build/Sxr.scala | 4 ++-- project/build/XSbt.scala | 16 ++++++++++++++-- util/log/ConsoleLogger.scala | 17 +++++++++-------- 17 files changed, 58 insertions(+), 51 deletions(-) diff --git a/cache/Cache.scala b/cache/Cache.scala index 21e89abc4..e394a8903 100644 --- a/cache/Cache.scala +++ b/cache/Cache.scala @@ -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]) { diff --git a/cache/SeparatedCache.scala b/cache/SeparatedCache.scala index 59bbbe379..523716ac3 100644 --- a/cache/SeparatedCache.scala +++ b/cache/SeparatedCache.scala @@ -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 } } diff --git a/cache/tracking/Tracked.scala b/cache/tracking/Tracked.scala index 10b37101f..9d2848b73 100644 --- a/cache/tracking/Tracked.scala +++ b/cache/tracking/Tracked.scala @@ -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 { diff --git a/compile/Eval.scala b/compile/Eval.scala index e829824d1..f75d301b7 100644 --- a/compile/Eval.scala +++ b/compile/Eval.scala @@ -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 } diff --git a/compile/LoggerReporter.scala b/compile/LoggerReporter.scala index 23ad160b9..bd4bad53c 100644 --- a/compile/LoggerReporter.scala +++ b/compile/LoggerReporter.scala @@ -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) }) } diff --git a/compile/persist/FileBasedStore.scala b/compile/persist/FileBasedStore.scala index 74d563a7c..419c172fb 100644 --- a/compile/persist/FileBasedStore.scala +++ b/compile/persist/FileBasedStore.scala @@ -8,7 +8,6 @@ package inc import sbinary._ import Operations.{read, write} import DefaultProtocol._ - import JavaIO._ object FileBasedStore { diff --git a/compile/persist/SourceFormat.scala b/compile/persist/SourceFormat.scala index 446c345fa..6bd6e9af6 100644 --- a/compile/persist/SourceFormat.scala +++ b/compile/persist/SourceFormat.scala @@ -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 diff --git a/ivy/Ivy.scala b/ivy/Ivy.scala index 57e19ec4b..7bc2d33fc 100644 --- a/ivy/Ivy.scala +++ b/ivy/Ivy.scala @@ -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 } } diff --git a/ivy/IvyActions.scala b/ivy/IvyActions.scala index 028c2dab5..f2b382f22 100644 --- a/ivy/IvyActions.scala +++ b/ivy/IvyActions.scala @@ -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. diff --git a/ivy/IvyConfigurations.scala b/ivy/IvyConfigurations.scala index 8906018f8..b151054bd 100644 --- a/ivy/IvyConfigurations.scala +++ b/ivy/IvyConfigurations.scala @@ -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]) { diff --git a/ivy/IvyScala.scala b/ivy/IvyScala.scala index c79909698..1e0406138 100644 --- a/ivy/IvyScala.scala +++ b/ivy/IvyScala.scala @@ -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 } diff --git a/ivy/MakePom.scala b/ivy/MakePom.scala index be09ecc48..7fbc42056 100644 --- a/ivy/MakePom.scala +++ b/ivy/MakePom.scala @@ -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 = ( 4.0.0 { 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 = {id} {name} diff --git a/main/TaskData.scala b/main/TaskData.scala index 04667c978..d828aa45e 100644 --- a/main/TaskData.scala +++ b/main/TaskData.scala @@ -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 { diff --git a/main/actions/Sync.scala b/main/actions/Sync.scala index f32127e1d..072c7054c 100644 --- a/main/actions/Sync.scala +++ b/main/actions/Sync.scala @@ -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 = diff --git a/project/build/Sxr.scala b/project/build/Sxr.scala index f78ddac19..cf3917f61 100644 --- a/project/build/Sxr.scala +++ b/project/build/Sxr.scala @@ -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" diff --git a/project/build/XSbt.scala b/project/build/XSbt.scala index 716926727..76b1957f3 100644 --- a/project/build/XSbt.scala +++ b/project/build/XSbt.scala @@ -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) + } } diff --git a/util/log/ConsoleLogger.scala b/util/log/ConsoleLogger.scala index f7229573e..c1a77e745 100644 --- a/util/log/ConsoleLogger.scala +++ b/util/log/ConsoleLogger.scala @@ -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 {