Merge pull request #13 from sbt/wip/packagenames2

package name change and test migration
This commit is contained in:
eugene yokota 2015-09-07 02:51:08 -04:00
commit 349254362d
86 changed files with 306 additions and 254 deletions

3
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,3 @@
```
$ sbt release
```

View File

@ -33,14 +33,10 @@ def commonSettings: Seq[Setting[_]] = Seq(
publishArtifact in Test := true
)
def testedBaseSettings: Seq[Setting[_]] =
commonSettings ++ testDependencies
lazy val utilRoot: Project = (project in file(".")).
// configs(Sxr.sxrConf).
aggregate(
utilInterface, utilControl, utilCollection, utilApplyMacro, utilComplete,
utilLogging, utilRelation, utilLogic, utilCache, utilTracking
utilLogging, utilRelation, utilLogic, utilCache, utilTracking, utilTesting
).
settings(
inThisBuild(Seq(
@ -65,7 +61,10 @@ lazy val utilRoot: Project = (project in file(".")).
name := "Util Root",
publish := {},
publishLocal := {},
publishArtifact := false
publishArtifact in Compile := false,
publishArtifact in Test := false,
publishArtifact := false,
customCommands
)
// defines Java structures used across Scala versions, such as the API structures and relationships extracted by
@ -86,8 +85,9 @@ lazy val utilControl = (project in internalPath / "util-control").
)
lazy val utilCollection = (project in internalPath / "util-collection").
dependsOn(utilTesting % Test).
settings(
testedBaseSettings,
commonSettings,
Util.keywordsSettings,
name := "Util Collection"
)
@ -95,26 +95,25 @@ lazy val utilCollection = (project in internalPath / "util-collection").
lazy val utilApplyMacro = (project in internalPath / "util-appmacro").
dependsOn(utilCollection).
settings(
testedBaseSettings,
commonSettings,
name := "Util Apply Macro",
libraryDependencies += scalaCompiler.value
)
// Command line-related utilities.
lazy val utilComplete = (project in internalPath / "util-complete").
dependsOn(utilCollection, utilControl).
dependsOn(utilCollection, utilControl, utilTesting % Test).
settings(
testedBaseSettings,
commonSettings,
name := "Util Completion",
libraryDependencies ++= Seq(jline, sbtIO),
crossScalaVersions := Seq(scala210, scala211)
libraryDependencies ++= Seq(jline, sbtIO)
)
// logging
lazy val utilLogging = (project in internalPath / "util-logging").
dependsOn(utilInterface).
dependsOn(utilInterface, utilTesting % Test).
settings(
testedBaseSettings,
commonSettings,
publishArtifact in (Test, packageBin) := true,
name := "Util Logging",
libraryDependencies += jline
@ -122,16 +121,17 @@ lazy val utilLogging = (project in internalPath / "util-logging").
// Relation
lazy val utilRelation = (project in internalPath / "util-relation").
dependsOn(utilTesting % Test).
settings(
testedBaseSettings,
commonSettings,
name := "Util Relation"
)
// A logic with restricted negation as failure for a unique, stable model
lazy val utilLogic = (project in internalPath / "util-logic").
dependsOn(utilCollection, utilRelation).
dependsOn(utilCollection, utilRelation, utilTesting % Test).
settings(
testedBaseSettings,
commonSettings,
name := "Util Logic"
)
@ -152,3 +152,21 @@ lazy val utilTracking = (project in internalPath / "util-tracking").
name := "Util Tracking",
libraryDependencies += sbtIO
)
// Internal utility for testing
lazy val utilTesting = (project in internalPath / "util-testing").
settings(
commonSettings,
name := "Util Testing",
libraryDependencies ++= Seq(scalaCheck, scalatest)
)
def customCommands: Seq[Setting[_]] = Seq(
commands += Command.command("release") { state =>
// "clean" ::
"so compile" ::
"so publishSigned" ::
"reload" ::
state
}
)

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package appmacro
import scala.reflect._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package appmacro
import scala.reflect._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package appmacro
import Classes.Applicative

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package appmacro
import Types.Id

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package appmacro
import scala.reflect._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package appmacro
import Types.Id

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbinary.{ CollectionTypes, DefaultProtocol, Format, Input, JavaFormats, Output => Out }
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream, OutputStream }

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import java.io.{ File, FileNotFoundException }
import sbinary.{ DefaultProtocol, Format, Operations }

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import java.io.{ File, IOException }
import sbinary.{ DefaultProtocol, Format }

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Types.:+:
import sbinary.{ DefaultProtocol, Format, Input, Output => Out }

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
import java.io.File
import Types.:+:

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
import Classes.Applicative
import Types._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Types._
import scala.reflect.Manifest

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
object Classes {
trait Applicative[M[_]] {

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 David MacIver, Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
trait Dag[Node <: Dag[Node]] {
self: Node =>

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Types._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
/** A mutable set interface that uses object identity to test for set membership.*/
trait IDSet[T] {

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
import java.lang.Runnable
import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue }

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
import Types._
import Classes.Applicative

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import collection.mutable

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Types._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
sealed trait SourcePosition

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Types._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
trait Show[T] {
def apply(t: T): String

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
trait ShowLines[A] {
def showLines(a: A): Seq[String]

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
object Signals {
val CONT = "CONT"

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
trait TypeFunctions {
type Id[X] = X

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
object Types extends Types

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import java.util.Locale

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2008 Mark Harrah */
package sbt.util.internal
package sbt.internal.util
import org.scalacheck._
import Prop._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
import org.scalacheck._
import Prop._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Types._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Types._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
/** Define our settings system */

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
import org.scalacheck._
import Prop._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import jline.console.ConsoleReader
import jline.console.history.{ FileHistory, MemoryHistory }
@ -128,7 +128,7 @@ final class FullReader(historyPath: Option[File], complete: Parser[_], val handl
protected[this] val reader =
{
val cr = JLine.createReader(historyPath)
sbt.util.internal.complete.JLineCompletion.installCustomCompletor(cr, complete)
sbt.internal.util.complete.JLineCompletion.installCustomCompletor(cr, complete)
cr
}
}

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
package complete
/**

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package complete
import java.lang.Character.{ toLowerCase => lower }

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package complete
import java.io.File

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
package complete
import History.number

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
package complete
import java.io.File

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
package complete
import jline.console.ConsoleReader

View File

@ -1,12 +1,12 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2010, 2011 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
package complete
import Parser._
import sbt.util.internal.Types.{ left, right, some }
import sbt.util.internal.Util.{ makeList, separate }
import sbt.internal.util.Types.{ left, right, some }
import sbt.internal.util.Util.{ makeList, separate }
/**
* A String parser that provides semi-automatic tab completion.

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
package complete
import Parser._

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package complete
object ProcessError {

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package complete
import Completion.{ token => ctoken, tokenDisplay }

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package complete
import DefaultParsers._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2008,2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
package complete
sealed trait UpperBound {

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package complete
object JLineTest {

View File

@ -1,54 +1,60 @@
package sbt.util.internal
package sbt.internal.util
package complete
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
import java.io.File
import sbt.io.IO._
class FileExamplesTest extends Specification {
class FileExamplesTest extends UnitSpec {
"listing all files in an absolute base directory" should {
"produce the entire base directory's contents" in new directoryStructure {
fileExamples().toList should containTheSameElementsAs(allRelativizedPaths)
"listing all files in an absolute base directory" should
"produce the entire base directory's contents" in {
val _ = new DirectoryStructure {
fileExamples().toList should contain theSameElementsAs (allRelativizedPaths)
}
}
"listing files with a prefix that matches none" should
"produce an empty list" in {
val _ = new DirectoryStructure(withCompletionPrefix = "z") {
fileExamples().toList shouldBe empty
}
}
"listing single-character prefixed files" should
"produce matching paths only" in {
val _ = new DirectoryStructure(withCompletionPrefix = "f") {
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
}
}
"listing directory-prefixed files" should
"produce matching paths only" in {
val _ = new DirectoryStructure(withCompletionPrefix = "far") {
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
}
}
it should "produce sub-dir contents only when appending a file separator to the directory" in {
val _ = new DirectoryStructure(withCompletionPrefix = "far" + File.separator) {
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
}
}
"listing files with a prefix that matches none" should {
"produce an empty list" in new directoryStructure(withCompletionPrefix = "z") {
fileExamples().toList should beEmpty
}
}
"listing single-character prefixed files" should {
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "f") {
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
}
}
"listing directory-prefixed files" should {
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "far") {
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
"listing files with a sub-path prefix" should
"produce matching paths only" in {
val _ = new DirectoryStructure(withCompletionPrefix = "far" + File.separator + "ba") {
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
}
}
"produce sub-dir contents only when appending a file separator to the directory" in new directoryStructure(withCompletionPrefix = "far" + File.separator) {
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
"completing a full path" should
"produce a list with an empty string" in {
val _ = new DirectoryStructure(withCompletionPrefix = "bazaar") {
fileExamples().toList shouldEqual List("")
}
}
}
"listing files with a sub-path prefix" should {
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "far" + File.separator + "ba") {
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
}
}
"completing a full path" should {
"produce a list with an empty string" in new directoryStructure(withCompletionPrefix = "bazaar") {
fileExamples().toList shouldEqual List("")
}
}
class directoryStructure(withCompletionPrefix: String = "") extends Scope with DelayedInit {
class DirectoryStructure(withCompletionPrefix: String = "") extends DelayedInit {
var fileExamples: FileExamples = _
var baseDir: File = _
var childFiles: List[File] = _

View File

@ -1,26 +1,23 @@
package sbt.util.internal
package sbt.internal.util
package complete
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
class FixedSetExamplesTest extends UnitSpec {
class FixedSetExamplesTest extends Specification {
"adding a prefix" should {
"produce a smaller set of examples with the prefix removed" in new examples {
fixedSetExamples.withAddedPrefix("f")() must containTheSameElementsAs(List("oo", "ool", "u"))
fixedSetExamples.withAddedPrefix("fo")() must containTheSameElementsAs(List("o", "ol"))
fixedSetExamples.withAddedPrefix("b")() must containTheSameElementsAs(List("ar"))
"adding a prefix" should "produce a smaller set of examples with the prefix removed" in {
val _ = new Examples {
fixedSetExamples.withAddedPrefix("f")() should contain theSameElementsAs (List("oo", "ool", "u"))
fixedSetExamples.withAddedPrefix("fo")() should contain theSameElementsAs (List("o", "ol"))
fixedSetExamples.withAddedPrefix("b")() should contain theSameElementsAs (List("ar"))
}
}
"without a prefix" should {
"produce the original set" in new examples {
fixedSetExamples() mustEqual exampleSet
"without a prefix" should "produce the original set" in {
val _ = new Examples {
fixedSetExamples() shouldBe exampleSet
}
}
trait examples extends Scope {
trait Examples {
val exampleSet = List("foo", "bar", "fool", "fu")
val fixedSetExamples = FixedSetExamples(exampleSet)
}

View File

@ -1,61 +1,64 @@
package sbt.util.internal
package sbt.internal.util
package complete
import org.specs2.mutable.Specification
import org.specs2.specification.Scope
import Completion._
class ParserWithExamplesTest extends Specification {
class ParserWithExamplesTest extends UnitSpec {
"listing a limited number of completions" should {
"grab only the needed number of elements from the iterable source of examples" in new parserWithLazyExamples {
parserWithExamples.completions(0)
examples.size shouldEqual maxNumberOfExamples
"listing a limited number of completions" should
"grab only the needed number of elements from the iterable source of examples" in {
val _ = new ParserWithLazyExamples {
parserWithExamples.completions(0)
examples.size shouldEqual maxNumberOfExamples
}
}
}
"listing only valid completions" should {
"use the delegate parser to remove invalid examples" in new parserWithValidExamples {
val validCompletions = Completions(Set(
suggestion("blue"),
suggestion("red")))
parserWithExamples.completions(0) shouldEqual validCompletions
"listing only valid completions" should
"use the delegate parser to remove invalid examples" in {
val _ = new ParserWithValidExamples {
val validCompletions = Completions(Set(
suggestion("blue"),
suggestion("red")))
parserWithExamples.completions(0) shouldEqual validCompletions
}
}
}
"listing valid completions in a derived parser" should {
"produce only valid examples that start with the character of the derivation" in new parserWithValidExamples {
val derivedCompletions = Completions(Set(
suggestion("lue")))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
"listing valid completions in a derived parser" should
"produce only valid examples that start with the character of the derivation" in {
val _ = new ParserWithValidExamples {
val derivedCompletions = Completions(Set(
suggestion("lue")))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
}
}
}
"listing valid and invalid completions" should {
"produce the entire source of examples" in new parserWithAllExamples {
val completions = Completions(examples.map(suggestion(_)).toSet)
parserWithExamples.completions(0) shouldEqual completions
"listing valid and invalid completions" should
"produce the entire source of examples" in {
val _ = new parserWithAllExamples {
val completions = Completions(examples.map(suggestion(_)).toSet)
parserWithExamples.completions(0) shouldEqual completions
}
}
}
"listing valid and invalid completions in a derived parser" should {
"produce only examples that start with the character of the derivation" in new parserWithAllExamples {
val derivedCompletions = Completions(Set(
suggestion("lue"),
suggestion("lock")))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
"listing valid and invalid completions in a derived parser" should
"produce only examples that start with the character of the derivation" in {
val _ = new parserWithAllExamples {
val derivedCompletions = Completions(Set(
suggestion("lue"),
suggestion("lock")))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
}
}
}
class parserWithLazyExamples extends parser(GrowableSourceOfExamples(), maxNumberOfExamples = 5, removeInvalidExamples = false)
class ParserWithLazyExamples extends ParserExample(GrowableSourceOfExamples(), maxNumberOfExamples = 5, removeInvalidExamples = false)
class parserWithValidExamples extends parser(removeInvalidExamples = true)
class ParserWithValidExamples extends ParserExample(removeInvalidExamples = true)
class parserWithAllExamples extends parser(removeInvalidExamples = false)
class parserWithAllExamples extends ParserExample(removeInvalidExamples = false)
case class parser(examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"),
case class ParserExample(examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"),
maxNumberOfExamples: Int = 25,
removeInvalidExamples: Boolean) extends Scope {
removeInvalidExamples: Boolean) {
import DefaultParsers._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import java.io.IOException

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
/** Defines a function to call as sbt exits.*/
trait ExitHook {

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2011 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
final class MessageOnlyException(override val toString: String) extends RuntimeException(toString)

View File

@ -1,17 +1,19 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
/** Implements the level-setting methods of Logger.*/
abstract class BasicLogger extends AbstractLogger {
private var traceEnabledVar = java.lang.Integer.MAX_VALUE
private var traceEnabledVar: Int = java.lang.Integer.MAX_VALUE
private var level: Level.Value = Level.Info
private var successEnabledVar = true
def successEnabled = synchronized { successEnabledVar }
def successEnabled: Boolean = synchronized { successEnabledVar }
def setSuccessEnabled(flag: Boolean): Unit = synchronized { successEnabledVar = flag }
def getLevel = synchronized { level }
def getLevel: Level.Value = synchronized { level }
def setLevel(newLevel: Level.Value): Unit = synchronized { level = newLevel }
def setTrace(level: Int): Unit = synchronized { traceEnabledVar = level }
def getTrace = synchronized { traceEnabledVar }
}
def getTrace: Int = synchronized { traceEnabledVar }
}

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
import scala.collection.mutable.ListBuffer
/**

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010, 2011 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
import java.io.{ BufferedWriter, PrintStream, PrintWriter }
import java.util.Locale

View File

@ -1,5 +1,6 @@
package sbt.util.internal
package sbt.internal.util
import sbt.util._
import java.io.{ BufferedWriter, PrintStream, PrintWriter }
sealed trait ConsoleOut {

View File

@ -1,7 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
/**
* A filter logger is used to delegate messages but not the logging level to another logger. This means

View File

@ -1,7 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
/** Promotes the simple Logger interface to the full AbstractLogger interface. */
class FullLogger(delegate: Logger) extends BasicLogger {

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
import java.io.{ File, PrintWriter }
/**

View File

@ -1,7 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
/**
* Provides a `java.io.Writer` interface to a `Logger`. Content is line-buffered and logged at `level`.

View File

@ -1,5 +1,6 @@
package sbt.util.internal
package sbt.internal.util
import sbt.util._
import java.io.PrintWriter
object MainLogging {

View File

@ -2,7 +2,9 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import sbt.util._
// note that setting the logging level on this logger has no effect on its behavior, only
// on the behavior of the delegates.

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Tony Sloane
*/
package sbt.util.internal
package sbt.internal.util
object StackTrace {
def isSbtClass(name: String) = name.startsWith("sbt") || name.startsWith("xsbt")

View File

@ -0,0 +1,28 @@
package sbt.util
abstract class AbstractLogger extends Logger {
def getLevel: Level.Value
def setLevel(newLevel: Level.Value): Unit
def setTrace(flag: Int): Unit
def getTrace: Int
final def traceEnabled: Boolean = getTrace >= 0
def successEnabled: Boolean
def setSuccessEnabled(flag: Boolean): Unit
def atLevel(level: Level.Value): Boolean = level.id >= getLevel.id
def control(event: ControlEvent.Value, message: => String): Unit
def logAll(events: Seq[LogEvent]): Unit
/** Defined in terms of other methods in Logger and should not be called from them. */
final def log(event: LogEvent): Unit = {
event match {
case s: Success => success(s.msg)
case l: Log => log(l.level, l.msg)
case t: Trace => trace(t.exception)
case setL: SetLevel => setLevel(setL.newLevel)
case setT: SetTrace => setTrace(setT.level)
case setS: SetSuccess => setSuccessEnabled(setS.enabled)
case c: ControlEvent => control(c.event, c.msg)
}
}
}

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.util
/**
* An enumeration defining the levels available for logging. A level includes all of the levels
@ -25,4 +25,4 @@ object Level extends Enumeration {
def apply(s: String) = values.find(s == _.toString)
/** Same as apply, defined for use in pattern matching. */
private[sbt] def unapply(s: String) = apply(s)
}
}

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah
*/
package sbt.util.internal
package sbt.util
sealed trait LogEvent extends NotNull
final class Success(val msg: String) extends LogEvent

View File

@ -1,39 +1,42 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.util
import xsbti.{ Logger => xLogger, F0 }
import xsbti.{ Maybe, Position, Problem, Severity }
import sys.process.ProcessLogger
import sbt.internal.util.{ BufferedLogger, FullLogger }
import java.io.File
abstract class AbstractLogger extends Logger {
def getLevel: Level.Value
def setLevel(newLevel: Level.Value): Unit
def setTrace(flag: Int): Unit
def getTrace: Int
final def traceEnabled: Boolean = getTrace >= 0
def successEnabled: Boolean
def setSuccessEnabled(flag: Boolean): Unit
/**
* This is intended to be the simplest logging interface for use by code that wants to log.
* It does not include configuring the logger.
*/
abstract class Logger extends xLogger {
final def verbose(message: => String): Unit = debug(message)
final def debug(message: => String): Unit = log(Level.Debug, message)
final def info(message: => String): Unit = log(Level.Info, message)
final def warn(message: => String): Unit = log(Level.Warn, message)
final def error(message: => String): Unit = log(Level.Error, message)
// Added by sys.process.ProcessLogger
final def err(message: => String): Unit = log(Level.Error, message)
// sys.process.ProcessLogger
final def out(message: => String): Unit = log(Level.Info, message)
def atLevel(level: Level.Value): Boolean = level.id >= getLevel.id
def control(event: ControlEvent.Value, message: => String): Unit
def ansiCodesSupported: Boolean = false
def logAll(events: Seq[LogEvent]): Unit
/** Defined in terms of other methods in Logger and should not be called from them. */
final def log(event: LogEvent): Unit = {
event match {
case s: Success => success(s.msg)
case l: Log => log(l.level, l.msg)
case t: Trace => trace(t.exception)
case setL: SetLevel => setLevel(setL.newLevel)
case setT: SetTrace => setTrace(setT.level)
case setS: SetSuccess => setSuccessEnabled(setS.enabled)
case c: ControlEvent => control(c.event, c.msg)
}
}
def trace(t: => Throwable): Unit
def success(message: => String): Unit
def log(level: Level.Value, message: => String): Unit
def debug(msg: F0[String]): Unit = log(Level.Debug, msg)
def warn(msg: F0[String]): Unit = log(Level.Warn, msg)
def info(msg: F0[String]): Unit = log(Level.Info, msg)
def error(msg: F0[String]): Unit = log(Level.Error, msg)
def trace(msg: F0[Throwable]): Unit = trace(msg.apply)
def log(level: Level.Value, msg: F0[String]): Unit = log(level, msg.apply)
}
object Logger {
@ -107,32 +110,3 @@ object Logger {
override def toString = s"[$severity] $pos: $message"
}
}
/**
* This is intended to be the simplest logging interface for use by code that wants to log.
* It does not include configuring the logger.
*/
trait Logger extends xLogger {
final def verbose(message: => String): Unit = debug(message)
final def debug(message: => String): Unit = log(Level.Debug, message)
final def info(message: => String): Unit = log(Level.Info, message)
final def warn(message: => String): Unit = log(Level.Warn, message)
final def error(message: => String): Unit = log(Level.Error, message)
// Added by sys.process.ProcessLogger
final def err(message: => String): Unit = log(Level.Error, message)
// sys.process.ProcessLogger
final def out(message: => String): Unit = log(Level.Info, message)
def ansiCodesSupported: Boolean = false
def trace(t: => Throwable): Unit
def success(message: => String): Unit
def log(level: Level.Value, message: => String): Unit
def debug(msg: F0[String]): Unit = log(Level.Debug, msg)
def warn(msg: F0[String]): Unit = log(Level.Warn, msg)
def info(msg: F0[String]): Unit = log(Level.Info, msg)
def error(msg: F0[String]): Unit = log(Level.Error, msg)
def trace(msg: F0[Throwable]): Unit = trace(msg.apply)
def log(level: Level.Value, msg: F0[String]): Unit = log(level, msg.apply)
}

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
import org.scalacheck._
import Prop._
@ -61,6 +61,7 @@ object Escapes extends Properties("Escapes") {
final case class EscapeAndNot(escape: EscapeSequence, notEscape: String) {
override def toString = s"EscapeAntNot(escape = [$escape], notEscape = [${notEscape.map(_.toInt)}])"
}
// 2.10.5 warns on "implicit numeric widening" but it looks like a bug: https://issues.scala-lang.org/browse/SI-8450
final case class EscapeSequence(content: String, terminator: Char) {
if (!content.isEmpty) {
assert(content.tail.forall(c => !isEscapeTerminator(c)), "Escape sequence content contains an escape terminator: '" + content + "'")

View File

@ -1,8 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah */
package sbt.util.internal
package sbt.internal.util
import sbt.util._
import org.scalacheck._
import Arbitrary.{ arbitrary => arb, _ }
import Gen.{ listOfN, oneOf }

View File

@ -1,4 +1,6 @@
package sbt.util.internal
package sbt.internal.util
import sbt.util._
object TestLogger {
def apply[T](f: Logger => T): T =

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package logic
import scala.annotation.tailrec

View File

@ -1,4 +1,4 @@
package sbt.util.internal
package sbt.internal.util
package logic
import org.scalacheck._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import Relation._

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import org.scalacheck._
import Prop._

View File

@ -0,0 +1,5 @@
package sbt.internal.util
import org.scalatest._
abstract class UnitSpec extends FlatSpec with Matchers

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
object ChangeReport {
def modified[T](files: Set[T]): ChangeReport[T] =

View File

@ -1,7 +1,7 @@
/* sbt -- Simple Build Tool
* Copyright 2009, 2010 Mark Harrah
*/
package sbt.util.internal
package sbt.internal.util
import java.io.{ File, IOException }
import CacheIO.{ fromFile, toFile }

View File

@ -5,7 +5,7 @@ object Dependencies {
lazy val scala210 = "2.10.5"
lazy val scala211 = "2.11.7"
lazy val sbtIO = "org.scala-sbt" %% "io" % "1.0.0-M1"
lazy val sbtIO = "org.scala-sbt" %% "io" % "1.0.0-M3"
lazy val jline = "jline" % "jline" % "2.11"
lazy val sbtSerialization = "org.scala-sbt" %% "serialization" % "0.1.2"
lazy val sbinary = "org.scala-tools.sbinary" %% "sbinary" % "0.4.2"
@ -23,10 +23,6 @@ object Dependencies {
lazy val scalaXml = scala211Module("scala-xml", "1.0.1")
lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.11.4"
lazy val specs2 = "org.specs2" %% "specs2" % "2.3.11"
lazy val testDependencies = libraryDependencies ++= Seq(
scalaCheck,
specs2
).map(_ % "test")
lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.12.4"
lazy val scalatest = "org.scalatest" %% "scalatest" % "2.2.4"
}

View File

@ -7,8 +7,10 @@ object Util {
lazy val generateKeywords = TaskKey[File]("generateKeywords")
lazy val javaOnlySettings = Seq[Setting[_]](
crossPaths := false,
compileOrder := CompileOrder.JavaThenScala,
unmanagedSourceDirectories in Compile <<= Seq(javaSource in Compile).join
unmanagedSourceDirectories in Compile <<= Seq(javaSource in Compile).join,
crossScalaVersions := Seq(Dependencies.scala211)
)
def getScalaKeywords: Set[String] =
@ -20,7 +22,7 @@ object Util {
{
val init = keywords.map(tn => '"' + tn + '"').mkString("Set(", ", ", ")")
val ObjectName = "ScalaKeywords"
val PackageName = "sbt.util.internal"
val PackageName = "sbt.internal.util"
val keywordsSrc =
"""package %s
object %s {

1
project/doge.sbt Normal file
View File

@ -0,0 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.3")