mirror of https://github.com/sbt/sbt.git
rework ConsoleLogger
can send output to a PrintWriter control over color, still need custom formatter replace IvyLogger with normal Logger
This commit is contained in:
parent
d4965daf2a
commit
3d0d640a9c
|
|
@ -15,7 +15,7 @@ import java.util.concurrent.Callable
|
|||
* This is used for compiled source jars so that the compilation need not be repeated for other projects on the same
|
||||
* machine.
|
||||
*/
|
||||
class ComponentManager(globalLock: xsbti.GlobalLock, provider: xsbti.ComponentProvider, val log: IvyLogger) extends NotNull
|
||||
class ComponentManager(globalLock: xsbti.GlobalLock, provider: xsbti.ComponentProvider, val log: Logger) extends NotNull
|
||||
{
|
||||
/** Get all of the files for component 'id', throwing an exception if no files exist for the component. */
|
||||
def files(id: String)(ifMissing: IfMissing): Iterable[File] =
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ private object IvySbt
|
|||
|
||||
/** Sets the resolvers for 'settings' to 'resolvers'. This is done by creating a new chain and making it the default.
|
||||
* 'other' is for resolvers that should be in a different chain. These are typically used for publishing or other actions. */
|
||||
private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], other: Seq[Resolver], localOnly: Boolean, log: IvyLogger)
|
||||
private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], other: Seq[Resolver], localOnly: Boolean, log: Logger)
|
||||
{
|
||||
def makeChain(label: String, name: String, rs: Seq[Resolver]) = {
|
||||
log.debug(label + " repositories:")
|
||||
|
|
@ -183,7 +183,7 @@ private object IvySbt
|
|||
val mainChain = makeChain("Default", "sbt-chain", resolvers)
|
||||
settings.setDefaultResolver(mainChain.getName)
|
||||
}
|
||||
private def resolverChain(name: String, resolvers: Seq[Resolver], localOnly: Boolean, log: IvyLogger): ChainResolver =
|
||||
private def resolverChain(name: String, resolvers: Seq[Resolver], localOnly: Boolean, log: Logger): ChainResolver =
|
||||
{
|
||||
val newDefault = new ChainResolver
|
||||
newDefault.setName(name)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ object IvyCache
|
|||
{
|
||||
def lockFile = new File(System.getProperty("user.home"), ".sbt.cache.lock")
|
||||
/** Caches the given 'file' with the given ID. It may be retrieved or cleared using this ID.*/
|
||||
def cacheJar(moduleID: ModuleID, file: File, lock: Option[xsbti.GlobalLock], log: IvyLogger)
|
||||
def cacheJar(moduleID: ModuleID, file: File, lock: Option[xsbti.GlobalLock], log: Logger)
|
||||
{
|
||||
val artifact = defaultArtifact(moduleID)
|
||||
val resolved = new ResolvedResource(new FileResource(new IvyFileRepository, file), moduleID.revision)
|
||||
|
|
@ -42,13 +42,13 @@ object IvyCache
|
|||
}
|
||||
}
|
||||
/** Clears the cache of the jar for the given ID.*/
|
||||
def clearCachedJar(id: ModuleID, lock: Option[xsbti.GlobalLock], log: IvyLogger)
|
||||
def clearCachedJar(id: ModuleID, lock: Option[xsbti.GlobalLock], log: Logger)
|
||||
{
|
||||
try { withCachedJar(id, lock, log)(_.delete) }
|
||||
catch { case e: Exception => log.debug("Error cleaning cached jar: " + e.toString) }
|
||||
}
|
||||
/** Copies the cached jar for the given ID to the directory 'toDirectory'. If the jar is not in the cache, NotInCache is thrown.*/
|
||||
def retrieveCachedJar(id: ModuleID, toDirectory: File, lock: Option[xsbti.GlobalLock], log: IvyLogger) =
|
||||
def retrieveCachedJar(id: ModuleID, toDirectory: File, lock: Option[xsbti.GlobalLock], log: Logger) =
|
||||
withCachedJar(id, lock, log) { cachedFile =>
|
||||
val copyTo = new File(toDirectory, cachedFile.getName)
|
||||
FileUtil.copy(cachedFile, copyTo, null)
|
||||
|
|
@ -56,7 +56,7 @@ object IvyCache
|
|||
}
|
||||
|
||||
/** Get the location of the cached jar for the given ID in the Ivy cache. If the jar is not in the cache, NotInCache is thrown .*/
|
||||
def withCachedJar[T](id: ModuleID, lock: Option[xsbti.GlobalLock], log: IvyLogger)(f: File => T): T =
|
||||
def withCachedJar[T](id: ModuleID, lock: Option[xsbti.GlobalLock], log: Logger)(f: File => T): T =
|
||||
{
|
||||
val cachedFile =
|
||||
try
|
||||
|
|
@ -71,7 +71,7 @@ object IvyCache
|
|||
if(cachedFile.exists) f(cachedFile) else throw new NotInCache(id)
|
||||
}
|
||||
/** Calls the given function with the default Ivy cache.*/
|
||||
def withDefaultCache[T](lock: Option[xsbti.GlobalLock], log: IvyLogger)(f: DefaultRepositoryCacheManager => T): T =
|
||||
def withDefaultCache[T](lock: Option[xsbti.GlobalLock], log: Logger)(f: DefaultRepositoryCacheManager => T): T =
|
||||
{
|
||||
val (ivy, local) = basicLocalIvy(lock, log)
|
||||
ivy.withIvy { ivy =>
|
||||
|
|
@ -82,7 +82,7 @@ object IvyCache
|
|||
}
|
||||
private def unknownOrigin(artifact: IvyArtifact) = ArtifactOrigin.unkwnown(artifact)
|
||||
/** A minimal Ivy setup with only a local resolver and the current directory as the base directory.*/
|
||||
private def basicLocalIvy(lock: Option[xsbti.GlobalLock], log: IvyLogger) =
|
||||
private def basicLocalIvy(lock: Option[xsbti.GlobalLock], log: Logger) =
|
||||
{
|
||||
val local = Resolver.defaultLocal(None)
|
||||
val paths = new IvyPaths(new File("."), None)
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@ sealed trait IvyConfiguration extends NotNull
|
|||
type This <: IvyConfiguration
|
||||
def lock: Option[xsbti.GlobalLock]
|
||||
def baseDirectory: File
|
||||
def log: IvyLogger
|
||||
def log: Logger
|
||||
def withBase(newBaseDirectory: File): This
|
||||
}
|
||||
final class InlineIvyConfiguration(val paths: IvyPaths, val resolvers: Seq[Resolver], val otherResolvers: Seq[Resolver],
|
||||
val moduleConfigurations: Seq[ModuleConfiguration], val localOnly: Boolean, val lock: Option[xsbti.GlobalLock],
|
||||
val log: IvyLogger) extends IvyConfiguration
|
||||
val log: Logger) extends IvyConfiguration
|
||||
{
|
||||
type This = InlineIvyConfiguration
|
||||
def baseDirectory = paths.baseDirectory
|
||||
def withBase(newBase: File) = new InlineIvyConfiguration(paths.withBase(newBase), resolvers, otherResolvers, moduleConfigurations, localOnly, lock, log)
|
||||
def changeResolvers(newResolvers: Seq[Resolver]) = new InlineIvyConfiguration(paths, newResolvers, otherResolvers, moduleConfigurations, localOnly, lock, log)
|
||||
}
|
||||
final class ExternalIvyConfiguration(val baseDirectory: File, val file: File, val lock: Option[xsbti.GlobalLock], val log: IvyLogger) extends IvyConfiguration
|
||||
final class ExternalIvyConfiguration(val baseDirectory: File, val file: File, val lock: Option[xsbti.GlobalLock], val log: Logger) extends IvyConfiguration
|
||||
{
|
||||
type This = ExternalIvyConfiguration
|
||||
def withBase(newBase: File) = new ExternalIvyConfiguration(newBase, file, lock, log)
|
||||
|
|
@ -37,7 +37,7 @@ object IvyConfiguration
|
|||
{
|
||||
/** Called to configure Ivy when inline resolvers are not specified.
|
||||
* This will configure Ivy with an 'ivy-settings.xml' file if there is one or else use default resolvers.*/
|
||||
def apply(paths: IvyPaths, lock: Option[xsbti.GlobalLock], localOnly: Boolean, log: IvyLogger): IvyConfiguration =
|
||||
def apply(paths: IvyPaths, lock: Option[xsbti.GlobalLock], localOnly: Boolean, log: Logger): IvyConfiguration =
|
||||
{
|
||||
log.debug("Autodetecting configuration.")
|
||||
val defaultIvyConfigFile = IvySbt.defaultIvyConfiguration(paths.baseDirectory)
|
||||
|
|
@ -93,7 +93,7 @@ object InlineConfiguration
|
|||
}
|
||||
object ModuleSettings
|
||||
{
|
||||
def apply(ivyScala: Option[IvyScala], validate: Boolean, module: => ModuleID)(baseDirectory: File, log: IvyLogger) =
|
||||
def apply(ivyScala: Option[IvyScala], validate: Boolean, module: => ModuleID)(baseDirectory: File, log: Logger) =
|
||||
{
|
||||
log.debug("Autodetecting dependencies.")
|
||||
val defaultPOMFile = IvySbt.defaultPOM(baseDirectory)
|
||||
|
|
|
|||
|
|
@ -5,17 +5,8 @@ package sbt
|
|||
|
||||
import org.apache.ivy.util.{Message, MessageLogger, MessageLoggerEngine}
|
||||
|
||||
trait IvyLogger extends NotNull
|
||||
{
|
||||
def info(msg: => String)
|
||||
def debug(msg: => String)
|
||||
def warn(msg: => String)
|
||||
def error(msg: => String)
|
||||
def verbose(msg: => String)
|
||||
}
|
||||
|
||||
/** Interface to Ivy logging. */
|
||||
private final class IvyLoggerInterface(logger: IvyLogger) extends MessageLogger
|
||||
private final class IvyLoggerInterface(logger: Logger) extends MessageLogger
|
||||
{
|
||||
def rawlog(msg: String, level: Int) = log(msg, level)
|
||||
def log(msg: String, level: Int)
|
||||
|
|
|
|||
Loading…
Reference in New Issue