Merge pull request #2139 from pdalpra/drop-procedure-syntax

Replace procedure syntax by explicit Unit annotation
This commit is contained in:
eugene yokota 2015-08-04 11:32:07 -04:00
commit 5a47e5d6ae
14 changed files with 72 additions and 75 deletions

View File

@ -38,7 +38,7 @@ object ReplaceMavenConfigurationMappings {
// NOTE - This code is copied from org.apache.ivy.plugins.parser.m2.PomModuleDescriptorBuilder // NOTE - This code is copied from org.apache.ivy.plugins.parser.m2.PomModuleDescriptorBuilder
// except with altered default configurations... // except with altered default configurations...
REPLACEMENT_MAPPINGS.put("compile", new PomModuleDescriptorBuilder.ConfMapper { REPLACEMENT_MAPPINGS.put("compile", new PomModuleDescriptorBuilder.ConfMapper {
def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = {
if (isOptional) { if (isOptional) {
dd.addDependencyConfiguration("optional", "compile(*)") dd.addDependencyConfiguration("optional", "compile(*)")
// FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there. // FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there.
@ -52,7 +52,7 @@ object ReplaceMavenConfigurationMappings {
} }
}) })
REPLACEMENT_MAPPINGS.put("provided", new PomModuleDescriptorBuilder.ConfMapper { REPLACEMENT_MAPPINGS.put("provided", new PomModuleDescriptorBuilder.ConfMapper {
def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = {
if (isOptional) { if (isOptional) {
dd.addDependencyConfiguration("optional", "compile(*)") dd.addDependencyConfiguration("optional", "compile(*)")
dd.addDependencyConfiguration("optional", "provided(*)") dd.addDependencyConfiguration("optional", "provided(*)")
@ -70,7 +70,7 @@ object ReplaceMavenConfigurationMappings {
}) })
REPLACEMENT_MAPPINGS.put("runtime", new PomModuleDescriptorBuilder.ConfMapper { REPLACEMENT_MAPPINGS.put("runtime", new PomModuleDescriptorBuilder.ConfMapper {
def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = {
if (isOptional) { if (isOptional) {
dd.addDependencyConfiguration("optional", "compile(*)") dd.addDependencyConfiguration("optional", "compile(*)")
dd.addDependencyConfiguration("optional", "provided(*)") dd.addDependencyConfiguration("optional", "provided(*)")
@ -86,7 +86,7 @@ object ReplaceMavenConfigurationMappings {
}) })
REPLACEMENT_MAPPINGS.put("test", new PomModuleDescriptorBuilder.ConfMapper { REPLACEMENT_MAPPINGS.put("test", new PomModuleDescriptorBuilder.ConfMapper {
def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = {
dd.addDependencyConfiguration("test", "runtime(*)") dd.addDependencyConfiguration("test", "runtime(*)")
// FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there. // FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there.
dd.addDependencyConfiguration("test", "master(compile)") dd.addDependencyConfiguration("test", "master(compile)")
@ -94,7 +94,7 @@ object ReplaceMavenConfigurationMappings {
}) })
REPLACEMENT_MAPPINGS.put("system", new PomModuleDescriptorBuilder.ConfMapper { REPLACEMENT_MAPPINGS.put("system", new PomModuleDescriptorBuilder.ConfMapper {
def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean) { def addMappingConfs(dd: DefaultDependencyDescriptor, isOptional: Boolean): Unit = {
// FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there. // FIX - Here we take a mroe conservative approach of depending on the compile configuration if master isn't there.
dd.addDependencyConfiguration("system", "master(compile)") dd.addDependencyConfiguration("system", "master(compile)")
} }

View File

@ -28,10 +28,10 @@ object ConflictWarning {
@deprecated("Warning on evicted modules is no longer done, so this is the same as `default`. Use a standard Ivy conflict manager.", "0.13.0") @deprecated("Warning on evicted modules is no longer done, so this is the same as `default`. Use a standard Ivy conflict manager.", "0.13.0")
def strict(label: String): ConflictWarning = ConflictWarning(label, Level.Error, true) def strict(label: String): ConflictWarning = ConflictWarning(label, Level.Error, true)
def apply(config: ConflictWarning, report: UpdateReport, log: Logger) { def apply(config: ConflictWarning, report: UpdateReport, log: Logger): Unit = {
processCrossVersioned(config, report, log) processCrossVersioned(config, report, log)
} }
private[this] def processCrossVersioned(config: ConflictWarning, report: UpdateReport, log: Logger) { private[this] def processCrossVersioned(config: ConflictWarning, report: UpdateReport, log: Logger): Unit = {
val crossMismatches = crossVersionMismatches(report) val crossMismatches = crossVersionMismatches(report)
if (crossMismatches.nonEmpty) { if (crossMismatches.nonEmpty) {
val pre = s"Modules were resolved with conflicting cross-version suffixes in ${config.label}:\n " val pre = s"Modules were resolved with conflicting cross-version suffixes in ${config.label}:\n "

View File

@ -113,7 +113,7 @@ private[sbt] object ConvertResolver {
{ {
val pattern = Collections.singletonList(Resolver.resolvePattern(repo.root, Resolver.mavenStyleBasePattern)) val pattern = Collections.singletonList(Resolver.resolvePattern(repo.root, Resolver.mavenStyleBasePattern))
final class PluginCapableResolver extends IBiblioResolver with ChecksumFriendlyURLResolver with DescriptorRequired { final class PluginCapableResolver extends IBiblioResolver with ChecksumFriendlyURLResolver with DescriptorRequired {
def setPatterns() { def setPatterns(): Unit = {
// done this way for access to protected methods. // done this way for access to protected methods.
setArtifactPatterns(pattern) setArtifactPatterns(pattern)
setIvyPatterns(pattern) setIvyPatterns(pattern)
@ -189,18 +189,18 @@ private[sbt] object ConvertResolver {
def hasExplicitURL(dd: DependencyDescriptor): Boolean = def hasExplicitURL(dd: DependencyDescriptor): Boolean =
dd.getAllDependencyArtifacts.exists(_.getUrl != null) dd.getAllDependencyArtifacts.exists(_.getUrl != null)
} }
private def initializeMavenStyle(resolver: IBiblioResolver, name: String, root: String) { private def initializeMavenStyle(resolver: IBiblioResolver, name: String, root: String): Unit = {
resolver.setName(name) resolver.setName(name)
resolver.setM2compatible(true) resolver.setM2compatible(true)
resolver.setRoot(root) resolver.setRoot(root)
} }
private def initializeSSHResolver(resolver: AbstractSshBasedResolver, repo: SshBasedRepository, settings: IvySettings) { private def initializeSSHResolver(resolver: AbstractSshBasedResolver, repo: SshBasedRepository, settings: IvySettings): Unit = {
resolver.setName(repo.name) resolver.setName(repo.name)
resolver.setPassfile(null) resolver.setPassfile(null)
initializePatterns(resolver, repo.patterns, settings) initializePatterns(resolver, repo.patterns, settings)
initializeConnection(resolver, repo.connection) initializeConnection(resolver, repo.connection)
} }
private def initializeConnection(resolver: AbstractSshBasedResolver, connection: RepositoryHelpers.SshConnection) { private def initializeConnection(resolver: AbstractSshBasedResolver, connection: RepositoryHelpers.SshConnection): Unit = {
import resolver._ import resolver._
import connection._ import connection._
hostname.foreach(setHost) hostname.foreach(setHost)
@ -216,7 +216,7 @@ private[sbt] object ConvertResolver {
setUser(user) setUser(user)
} }
} }
private def initializePatterns(resolver: AbstractPatternsBasedResolver, patterns: Patterns, settings: IvySettings) { private def initializePatterns(resolver: AbstractPatternsBasedResolver, patterns: Patterns, settings: IvySettings): Unit = {
resolver.setM2compatible(patterns.isMavenCompatible) resolver.setM2compatible(patterns.isMavenCompatible)
resolver.setDescriptor(if (patterns.descriptorOptional) BasicResolver.DESCRIPTOR_OPTIONAL else BasicResolver.DESCRIPTOR_REQUIRED) resolver.setDescriptor(if (patterns.descriptorOptional) BasicResolver.DESCRIPTOR_OPTIONAL else BasicResolver.DESCRIPTOR_REQUIRED)
resolver.setCheckconsistency(!patterns.skipConsistencyCheck) resolver.setCheckconsistency(!patterns.skipConsistencyCheck)

View File

@ -21,9 +21,9 @@ private[sbt] object CustomXmlParser extends XmlModuleDescriptorParser {
super.setResource(new URLResource(url)) super.setResource(new URLResource(url))
super.setInput(url) super.setInput(url)
} }
def setInput(bytes: Array[Byte]) { setInput(new ByteArrayInputStream(bytes)) } def setInput(bytes: Array[Byte]): Unit = setInput(new ByteArrayInputStream(bytes))
/** Overridden because the super implementation overwrites the module descriptor.*/ /** Overridden because the super implementation overwrites the module descriptor.*/
override def setResource(res: Resource) {} override def setResource(res: Resource): Unit = ()
override def setMd(md: DefaultModuleDescriptor) = override def setMd(md: DefaultModuleDescriptor) =
{ {
super.setMd(md) super.setMd(md)

View File

@ -231,7 +231,7 @@ final class IvySbt(val configuration: IvyConfiguration) {
addScalaToolDependencies(dmd, parser, is) addScalaToolDependencies(dmd, parser, is)
(dmd, parser.getDefaultConf) (dmd, parser.getDefaultConf)
} }
private def addScalaToolDependencies(dmd: DefaultModuleDescriptor, parser: CustomXmlParser.CustomParser, is: IvyScala) { private def addScalaToolDependencies(dmd: DefaultModuleDescriptor, parser: CustomXmlParser.CustomParser, is: IvyScala): Unit = {
IvySbt.addConfigurations(dmd, Configurations.ScalaTool :: Nil) IvySbt.addConfigurations(dmd, Configurations.ScalaTool :: Nil)
IvySbt.addDependencies(dmd, ScalaArtifacts.toolDependencies(is.scalaOrganization, is.scalaFullVersion), parser) IvySbt.addDependencies(dmd, ScalaArtifacts.toolDependencies(is.scalaOrganization, is.scalaFullVersion), parser)
} }
@ -257,7 +257,7 @@ private[sbt] object IvySbt {
def defaultIvyConfiguration(project: File) = new File(project, DefaultIvyConfigFilename) def defaultIvyConfiguration(project: File) = new File(project, DefaultIvyConfigFilename)
def defaultPOM(project: File) = new File(project, DefaultMavenFilename) def defaultPOM(project: File) = new File(project, DefaultMavenFilename)
def loadURI(is: IvySettings, uri: URI) { def loadURI(is: IvySettings, uri: URI): Unit = {
if (uri.getScheme == "file") if (uri.getScheme == "file")
is.load(new File(uri)) // IVY-1114 is.load(new File(uri)) // IVY-1114
else else
@ -268,7 +268,7 @@ private[sbt] object IvySbt {
* Sets the resolvers for 'settings' to 'resolvers'. This is done by creating a new chain and making it the default. * 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. * '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, updateOptions: UpdateOptions, log: Logger) { private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], other: Seq[Resolver], localOnly: Boolean, updateOptions: UpdateOptions, log: Logger): Unit = {
def makeChain(label: String, name: String, rs: Seq[Resolver]) = { def makeChain(label: String, name: String, rs: Seq[Resolver]) = {
log.debug(label + " repositories:") log.debug(label + " repositories:")
val chain = resolverChain(name, rs, localOnly, settings, updateOptions, log) val chain = resolverChain(name, rs, localOnly, settings, updateOptions, log)
@ -304,7 +304,7 @@ private[sbt] object IvySbt {
} }
} }
def addResolvers(resolvers: Seq[Resolver], settings: IvySettings, log: Logger) { def addResolvers(resolvers: Seq[Resolver], settings: IvySettings, log: Logger): Unit = {
for (r <- resolvers) { for (r <- resolvers) {
log.debug("\t" + r) log.debug("\t" + r)
settings.addResolver(ConvertResolver(r, settings, log)) settings.addResolver(ConvertResolver(r, settings, log))
@ -320,7 +320,7 @@ private[sbt] object IvySbt {
import collection.JavaConversions._ import collection.JavaConversions._
artifact.getQualifiedExtraAttributes.keys.exists(_.asInstanceOf[String] startsWith "m:") artifact.getQualifiedExtraAttributes.keys.exists(_.asInstanceOf[String] startsWith "m:")
} }
private def setModuleConfigurations(settings: IvySettings, moduleConfigurations: Seq[ModuleConfiguration], log: Logger) { private def setModuleConfigurations(settings: IvySettings, moduleConfigurations: Seq[ModuleConfiguration], log: Logger): Unit = {
val existing = settings.getResolverNames val existing = settings.getResolverNames
for (moduleConf <- moduleConfigurations) { for (moduleConf <- moduleConfigurations) {
import moduleConf._ import moduleConf._
@ -332,11 +332,11 @@ private[sbt] object IvySbt {
settings.addModuleConfiguration(attributes, settings.getMatcher(EXACT_OR_REGEXP), resolver.name, null, null, null) settings.addModuleConfiguration(attributes, settings.getMatcher(EXACT_OR_REGEXP), resolver.name, null, null, null)
} }
} }
private def configureCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]) { private def configureCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]): Unit = {
configureResolutionCache(settings, localOnly, resCacheDir) configureResolutionCache(settings, localOnly, resCacheDir)
configureRepositoryCache(settings, localOnly) configureRepositoryCache(settings, localOnly)
} }
private[this] def configureResolutionCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]) { private[this] def configureResolutionCache(settings: IvySettings, localOnly: Boolean, resCacheDir: Option[File]): Unit = {
val base = resCacheDir getOrElse settings.getDefaultResolutionCacheBasedir val base = resCacheDir getOrElse settings.getDefaultResolutionCacheBasedir
settings.setResolutionCacheManager(new ResolutionCache(base, settings)) settings.setResolutionCacheManager(new ResolutionCache(base, settings))
} }
@ -385,7 +385,7 @@ private[sbt] object IvySbt {
case _ => false case _ => false
} }
// ignore the original resolver wherever possible to avoid issues like #704 // ignore the original resolver wherever possible to avoid issues like #704
override def saveResolvers(descriptor: ModuleDescriptor, metadataResolverName: String, artifactResolverName: String) {} override def saveResolvers(descriptor: ModuleDescriptor, metadataResolverName: String, artifactResolverName: String): Unit = ()
} }
manager.setArtifactPattern(PluginPattern + manager.getArtifactPattern) manager.setArtifactPattern(PluginPattern + manager.getArtifactPattern)
manager.setDataFilePattern(PluginPattern + manager.getDataFilePattern) manager.setDataFilePattern(PluginPattern + manager.getDataFilePattern)
@ -411,12 +411,12 @@ private[sbt] object IvySbt {
dmd.addExtraAttributeNamespace("e", "http://ant.apache.org/ivy/extra") dmd.addExtraAttributeNamespace("e", "http://ant.apache.org/ivy/extra")
/** Adds the ivy.xml main artifact. */ /** Adds the ivy.xml main artifact. */
private def addMainArtifact(moduleID: DefaultModuleDescriptor) { private def addMainArtifact(moduleID: DefaultModuleDescriptor): Unit = {
val artifact = DefaultArtifact.newIvyArtifact(moduleID.getResolvedModuleRevisionId, moduleID.getPublicationDate) val artifact = DefaultArtifact.newIvyArtifact(moduleID.getResolvedModuleRevisionId, moduleID.getPublicationDate)
moduleID.setModuleArtifact(artifact) moduleID.setModuleArtifact(artifact)
moduleID.check() moduleID.check()
} }
private def setConflictManager(moduleID: DefaultModuleDescriptor, conflict: ConflictManager, is: IvySettings) { private def setConflictManager(moduleID: DefaultModuleDescriptor, conflict: ConflictManager, is: IvySettings): Unit = {
val mid = ModuleId.newInstance(conflict.organization, conflict.module) val mid = ModuleId.newInstance(conflict.organization, conflict.module)
val matcher = is.getMatcher(PatternMatcher.EXACT_OR_REGEXP) val matcher = is.getMatcher(PatternMatcher.EXACT_OR_REGEXP)
val manager = is.getConflictManager(conflict.name) val manager = is.getConflictManager(conflict.name)
@ -555,7 +555,7 @@ private[sbt] object IvySbt {
} }
/** This method is used to add inline dependencies to the provided module. */ /** This method is used to add inline dependencies to the provided module. */
def addDependencies(moduleID: DefaultModuleDescriptor, dependencies: Seq[ModuleID], parser: CustomXmlParser.CustomParser) { def addDependencies(moduleID: DefaultModuleDescriptor, dependencies: Seq[ModuleID], parser: CustomXmlParser.CustomParser): Unit = {
val converted = dependencies map { dependency => convertDependency(moduleID, dependency, parser) } val converted = dependencies map { dependency => convertDependency(moduleID, dependency, parser) }
val unique = if (hasDuplicateDependencies(converted)) mergeDuplicateDefinitions(converted) else converted val unique = if (hasDuplicateDependencies(converted)) mergeDuplicateDefinitions(converted) else converted
unique foreach moduleID.addDependency unique foreach moduleID.addDependency

View File

@ -61,7 +61,7 @@ object UpdateLogging extends Enumeration {
object IvyActions { object IvyActions {
/** Installs the dependencies of the given 'module' from the resolver named 'from' to the resolver named 'to'.*/ /** Installs the dependencies of the given 'module' from the resolver named 'from' to the resolver named 'to'.*/
def install(module: IvySbt#Module, from: String, to: String, log: Logger) { def install(module: IvySbt#Module, from: String, to: String, log: Logger): Unit = {
module.withModule(log) { (ivy, md, default) => module.withModule(log) { (ivy, md, default) =>
for (dependency <- md.getDependencies) { for (dependency <- md.getDependencies) {
log.info("Installing " + dependency) log.info("Installing " + dependency)
@ -89,7 +89,7 @@ object IvyActions {
} }
/** Creates a Maven pom from the given Ivy configuration*/ /** Creates a Maven pom from the given Ivy configuration*/
def makePom(module: IvySbt#Module, configuration: MakePomConfiguration, log: Logger) { def makePom(module: IvySbt#Module, configuration: MakePomConfiguration, log: Logger): Unit = {
import configuration.{ allRepositories, moduleInfo, configurations, extra, file, filterRepositories, process, includeTypes } import configuration.{ allRepositories, moduleInfo, configurations, extra, file, filterRepositories, process, includeTypes }
module.withModule(log) { (ivy, md, default) => module.withModule(log) { (ivy, md, default) =>
(new MakePom(log)).write(ivy, md, moduleInfo, configurations, includeTypes, extra, process, filterRepositories, allRepositories, file) (new MakePom(log)).write(ivy, md, moduleInfo, configurations, includeTypes, extra, process, filterRepositories, allRepositories, file)
@ -112,7 +112,7 @@ object IvyActions {
def deliveredFile(ivy: Ivy, pattern: String, md: ModuleDescriptor): File = def deliveredFile(ivy: Ivy, pattern: String, md: ModuleDescriptor): File =
ivy.getSettings.resolveFile(IvyPatternHelper.substitute(pattern, md.getResolvedModuleRevisionId)) ivy.getSettings.resolveFile(IvyPatternHelper.substitute(pattern, md.getResolvedModuleRevisionId))
def publish(module: IvySbt#Module, configuration: PublishConfiguration, log: Logger) { def publish(module: IvySbt#Module, configuration: PublishConfiguration, log: Logger): Unit = {
import configuration._ import configuration._
module.withModule(log) { module.withModule(log) {
case (ivy, md, default) => case (ivy, md, default) =>
@ -368,7 +368,7 @@ object IvyActions {
} }
} }
} }
private[this] def checkFilesPresent(artifacts: Seq[(IArtifact, File)]) { private[this] def checkFilesPresent(artifacts: Seq[(IArtifact, File)]): Unit = {
val missing = artifacts filter { case (a, file) => !file.exists } val missing = artifacts filter { case (a, file) => !file.exists }
if (missing.nonEmpty) if (missing.nonEmpty)
sys.error("Missing files for publishing:\n\t" + missing.map(_._2.getAbsolutePath).mkString("\n\t")) sys.error("Missing files for publishing:\n\t" + missing.map(_._2.getAbsolutePath).mkString("\n\t"))

View File

@ -28,7 +28,7 @@ private object NotInCache {
class IvyCache(val ivyHome: Option[File]) { class IvyCache(val ivyHome: Option[File]) {
def lockFile = new File(ivyHome getOrElse Path.userHome, ".sbt.cache.lock") def lockFile = new File(ivyHome getOrElse Path.userHome, ".sbt.cache.lock")
/** Caches the given 'file' with the given ID. It may be retrieved or cleared using this ID.*/ /** 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: Logger) { def cacheJar(moduleID: ModuleID, file: File, lock: Option[xsbti.GlobalLock], log: Logger): Unit = {
val artifact = defaultArtifact(moduleID) val artifact = defaultArtifact(moduleID)
val resolved = new ResolvedResource(new FileResource(new IvyFileRepository, file), moduleID.revision) val resolved = new ResolvedResource(new FileResource(new IvyFileRepository, file), moduleID.revision)
withDefaultCache(lock, log) { cache => withDefaultCache(lock, log) { cache =>
@ -37,7 +37,7 @@ class IvyCache(val ivyHome: Option[File]) {
} }
} }
/** Clears the cache of the jar for the given ID.*/ /** Clears the cache of the jar for the given ID.*/
def clearCachedJar(id: ModuleID, lock: Option[xsbti.GlobalLock], log: Logger) { def clearCachedJar(id: ModuleID, lock: Option[xsbti.GlobalLock], log: Logger): Unit = {
try { withCachedJar(id, lock, log)(_.delete) } try { withCachedJar(id, lock, log)(_.delete) }
catch { case e: Exception => log.debug("Error cleaning cached jar: " + e.toString) } catch { case e: Exception => log.debug("Error cleaning cached jar: " + e.toString) }
} }
@ -87,7 +87,7 @@ class IvyCache(val ivyHome: Option[File]) {
} }
/** Required by Ivy for copying to the cache.*/ /** Required by Ivy for copying to the cache.*/
private class FileDownloader extends ResourceDownloader with NotNull { private class FileDownloader extends ResourceDownloader with NotNull {
def download(artifact: IvyArtifact, resource: Resource, dest: File) { def download(artifact: IvyArtifact, resource: Resource, dest: File): Unit = {
if (dest.exists()) dest.delete() if (dest.exists()) dest.delete()
val part = new File(dest.getAbsolutePath + ".part") val part = new File(dest.getAbsolutePath + ".part")
FileUtil.copy(resource.openStream, part, null) FileUtil.copy(resource.openStream, part, null)

View File

@ -7,8 +7,8 @@ import org.apache.ivy.util.{ Message, MessageLogger, MessageLoggerEngine }
/** Interface to Ivy logging. */ /** Interface to Ivy logging. */
private final class IvyLoggerInterface(logger: Logger) extends MessageLogger { private final class IvyLoggerInterface(logger: Logger) extends MessageLogger {
def rawlog(msg: String, level: Int) = log(msg, level) def rawlog(msg: String, level: Int): Unit = log(msg, level)
def log(msg: String, level: Int) { def log(msg: String, level: Int): Unit = {
import Message.{ MSG_DEBUG, MSG_VERBOSE, MSG_INFO, MSG_WARN, MSG_ERR } import Message.{ MSG_DEBUG, MSG_VERBOSE, MSG_INFO, MSG_WARN, MSG_ERR }
level match { level match {
case MSG_DEBUG => debug(msg) case MSG_DEBUG => debug(msg)
@ -20,32 +20,32 @@ private final class IvyLoggerInterface(logger: Logger) extends MessageLogger {
} }
//DEBUG level messages are very verbose and rarely useful to users. //DEBUG level messages are very verbose and rarely useful to users.
// TODO: provide access to this information some other way // TODO: provide access to this information some other way
def debug(msg: String) {} def debug(msg: String): Unit = ()
def verbose(msg: String) = logger.verbose(msg) def verbose(msg: String): Unit = logger.verbose(msg)
def deprecated(msg: String) = warn(msg) def deprecated(msg: String): Unit = warn(msg)
def info(msg: String) = logger.info(msg) def info(msg: String): Unit = logger.info(msg)
def rawinfo(msg: String) = info(msg) def rawinfo(msg: String): Unit = info(msg)
def warn(msg: String) = logger.warn(msg) def warn(msg: String): Unit = logger.warn(msg)
def error(msg: String) = if (SbtIvyLogger.acceptError(msg)) logger.error(msg) def error(msg: String): Unit = if (SbtIvyLogger.acceptError(msg)) logger.error(msg)
private def emptyList = java.util.Collections.emptyList[String] private def emptyList = java.util.Collections.emptyList[String]
def getProblems = emptyList def getProblems = emptyList
def getWarns = emptyList def getWarns = emptyList
def getErrors = emptyList def getErrors = emptyList
def clearProblems = () def clearProblems(): Unit = ()
def sumupProblems = clearProblems() def sumupProblems(): Unit = clearProblems()
def progress = () def progress(): Unit = ()
def endProgress = () def endProgress(): Unit = ()
def endProgress(msg: String) = info(msg) def endProgress(msg: String): Unit = info(msg)
def isShowProgress = false def isShowProgress = false
def setShowProgress(progress: Boolean) {} def setShowProgress(progress: Boolean): Unit = ()
} }
private final class SbtMessageLoggerEngine extends MessageLoggerEngine { private final class SbtMessageLoggerEngine extends MessageLoggerEngine {
/** This is a hack to filter error messages about 'unknown resolver ...'. */ /** This is a hack to filter error messages about 'unknown resolver ...'. */
override def error(msg: String) = if (SbtIvyLogger.acceptError(msg)) super.error(msg) override def error(msg: String): Unit = if (SbtIvyLogger.acceptError(msg)) super.error(msg)
override def sumupProblems = clearProblems() override def sumupProblems(): Unit = clearProblems()
} }
private object SbtIvyLogger { private object SbtIvyLogger {
val UnknownResolver = "unknown resolver" val UnknownResolver = "unknown resolver"

View File

@ -37,7 +37,7 @@ final case class IvyScala(scalaFullVersion: String, scalaBinaryVersion: String,
private object IvyScala { private object IvyScala {
/** Performs checks/adds filters on Scala dependencies (if enabled in IvyScala). */ /** Performs checks/adds filters on Scala dependencies (if enabled in IvyScala). */
def checkModule(module: DefaultModuleDescriptor, conf: String, log: Logger)(check: IvyScala) { def checkModule(module: DefaultModuleDescriptor, conf: String, log: Logger)(check: IvyScala): Unit = {
if (check.checkExplicit) if (check.checkExplicit)
checkDependencies(module, check.scalaBinaryVersion, check.configurations, log) checkDependencies(module, check.scalaBinaryVersion, check.configurations, log)
if (check.filterImplicit) if (check.filterImplicit)
@ -45,12 +45,12 @@ private object IvyScala {
if (check.overrideScalaVersion) if (check.overrideScalaVersion)
overrideScalaVersion(module, check.scalaFullVersion) overrideScalaVersion(module, check.scalaFullVersion)
} }
def overrideScalaVersion(module: DefaultModuleDescriptor, version: String) { def overrideScalaVersion(module: DefaultModuleDescriptor, version: String): Unit = {
overrideVersion(module, Organization, LibraryID, version) overrideVersion(module, Organization, LibraryID, version)
overrideVersion(module, Organization, CompilerID, version) overrideVersion(module, Organization, CompilerID, version)
overrideVersion(module, Organization, ReflectID, version) overrideVersion(module, Organization, ReflectID, version)
} }
def overrideVersion(module: DefaultModuleDescriptor, org: String, name: String, version: String) { def overrideVersion(module: DefaultModuleDescriptor, org: String, name: String, version: String): Unit = {
val id = new ModuleId(org, name) val id = new ModuleId(org, name)
val over = new OverrideDependencyDescriptorMediator(null, version) val over = new OverrideDependencyDescriptorMediator(null, version)
module.addDependencyDescriptorMediator(id, ExactPatternMatcher.INSTANCE, over) module.addDependencyDescriptorMediator(id, ExactPatternMatcher.INSTANCE, over)
@ -60,7 +60,7 @@ private object IvyScala {
* Checks the immediate dependencies of module for dependencies on scala jars and verifies that the version on the * Checks the immediate dependencies of module for dependencies on scala jars and verifies that the version on the
* dependencies matches scalaVersion. * dependencies matches scalaVersion.
*/ */
private def checkDependencies(module: ModuleDescriptor, scalaBinaryVersion: String, configurations: Iterable[Configuration], log: Logger) { private def checkDependencies(module: ModuleDescriptor, scalaBinaryVersion: String, configurations: Iterable[Configuration], log: Logger): Unit = {
val configSet = if (configurations.isEmpty) (c: String) => true else configurationSet(configurations) val configSet = if (configurations.isEmpty) (c: String) => true else configurationSet(configurations)
def binaryScalaWarning(dep: DependencyDescriptor): Option[String] = def binaryScalaWarning(dep: DependencyDescriptor): Option[String] =
{ {
@ -88,7 +88,7 @@ private object IvyScala {
* done because these jars are provided by the ScalaInstance of the project. The version of Scala to use * done because these jars are provided by the ScalaInstance of the project. The version of Scala to use
* is done by setting scalaVersion in the project definition. * is done by setting scalaVersion in the project definition.
*/ */
private def excludeScalaJars(module: DefaultModuleDescriptor, configurations: Iterable[Configuration]) { private def excludeScalaJars(module: DefaultModuleDescriptor, configurations: Iterable[Configuration]): Unit = {
val configurationNames = val configurationNames =
{ {
val names = module.getConfigurationsNames val names = module.getConfigurationsNames

View File

@ -83,9 +83,8 @@ class MakePom(val log: Logger) {
write(process(toPom(ivy, module, moduleInfo, configurations, includeTypes, extra, filterRepositories, allRepositories)), output) write(process(toPom(ivy, module, moduleInfo, configurations, includeTypes, extra, filterRepositories, allRepositories)), output)
// use \n as newline because toString uses PrettyPrinter, which hard codes line endings to be \n // use \n as newline because toString uses PrettyPrinter, which hard codes line endings to be \n
def write(node: XNode, output: File): Unit = write(toString(node), output, "\n") def write(node: XNode, output: File): Unit = write(toString(node), output, "\n")
def write(xmlString: String, output: File, newline: String) { def write(xmlString: String, output: File, newline: String): Unit =
IO.write(output, "<?xml version='1.0' encoding='" + IO.utf8.name + "'?>" + newline + xmlString) IO.write(output, "<?xml version='1.0' encoding='" + IO.utf8.name + "'?>" + newline + xmlString)
}
def toString(node: XNode): String = new PrettyPrinter(1000, 4).format(node) def toString(node: XNode): String = new PrettyPrinter(1000, 4).format(node)
@deprecated("Use `toPom(Ivy, ModuleDescriptor, ModuleInfo, Option[Iterable[Configuration]], Set[String], NodeSeq, MavenRepository => Boolean, Boolean)` instead", "0.11.2") @deprecated("Use `toPom(Ivy, ModuleDescriptor, ModuleInfo, Option[Iterable[Configuration]], Set[String], NodeSeq, MavenRepository => Boolean, Boolean)` instead", "0.11.2")

View File

@ -70,12 +70,12 @@ class ProjectResolver(name: String, map: Map[ModuleRevisionId, ModuleDescriptor]
// doesn't support publishing // doesn't support publishing
def publish(artifact: IArtifact, src: File, overwrite: Boolean) = sys.error("Publish not supported by ProjectResolver") def publish(artifact: IArtifact, src: File, overwrite: Boolean) = sys.error("Publish not supported by ProjectResolver")
def beginPublishTransaction(module: ModuleRevisionId, overwrite: Boolean) {} def beginPublishTransaction(module: ModuleRevisionId, overwrite: Boolean): Unit = ()
def abortPublishTransaction() {} def abortPublishTransaction(): Unit = ()
def commitPublishTransaction() {} def commitPublishTransaction(): Unit = ()
def reportFailure() {} def reportFailure(): Unit = ()
def reportFailure(art: IArtifact) {} def reportFailure(art: IArtifact): Unit = ()
def listOrganisations() = new Array[OrganisationEntry](0) def listOrganisations() = new Array[OrganisationEntry](0)
def listModules(org: OrganisationEntry) = new Array[ModuleEntry](0) def listModules(org: OrganisationEntry) = new Array[ModuleEntry](0)
@ -85,8 +85,8 @@ class ProjectResolver(name: String, map: Map[ModuleRevisionId, ModuleDescriptor]
private[this] var settings: Option[ResolverSettings] = None private[this] var settings: Option[ResolverSettings] = None
def dumpSettings() {} def dumpSettings(): Unit = ()
def setSettings(settings: ResolverSettings) { this.settings = Some(settings) } def setSettings(settings: ResolverSettings): Unit = { this.settings = Some(settings) }
def getRepositoryCacheManager = settings match { case Some(s) => s.getDefaultRepositoryCacheManager; case None => sys.error("No settings defined for ProjectResolver") } def getRepositoryCacheManager = settings match { case Some(s) => s.getDefaultRepositoryCacheManager; case None => sys.error("No settings defined for ProjectResolver") }
} }

View File

@ -28,7 +28,7 @@ private[sbt] final class ResolutionCache(base: File, settings: IvySettings) exte
private[this] val reportBase: File = new File(base, ReportDirectory) private[this] val reportBase: File = new File(base, ReportDirectory)
def getResolutionCacheRoot: File = base def getResolutionCacheRoot: File = base
def clean() { IO.delete(base) } def clean(): Unit = IO.delete(base)
override def toString = Name override def toString = Name
def getResolvedIvyFileInCache(mrid: ModuleRevisionId): File = def getResolvedIvyFileInCache(mrid: ModuleRevisionId): File =
@ -66,7 +66,7 @@ private[sbt] object ResolutionCache {
* Removes cached files from the resolution cache for the module with ID `mrid` * Removes cached files from the resolution cache for the module with ID `mrid`
* and the resolveId (as set on `ResolveOptions`). * and the resolveId (as set on `ResolveOptions`).
*/ */
private[sbt] def cleanModule(mrid: ModuleRevisionId, resolveId: String, manager: ResolutionCacheManager) { private[sbt] def cleanModule(mrid: ModuleRevisionId, resolveId: String, manager: ResolutionCacheManager): Unit = {
val files = val files =
Option(manager.getResolvedIvyFileInCache(mrid)).toList ::: Option(manager.getResolvedIvyFileInCache(mrid)).toList :::
Option(manager.getResolvedIvyPropertiesInCache(mrid)).toList ::: Option(manager.getResolvedIvyPropertiesInCache(mrid)).toList :::

View File

@ -8,8 +8,6 @@ import java.util.Locale
object StringUtilities { object StringUtilities {
@deprecated("Different use cases require different normalization. Use Project.normalizeModuleID or normalizeProjectID instead.", "0.13.0") @deprecated("Different use cases require different normalization. Use Project.normalizeModuleID or normalizeProjectID instead.", "0.13.0")
def normalize(s: String) = s.toLowerCase(Locale.ENGLISH).replaceAll("""\W+""", "-") def normalize(s: String) = s.toLowerCase(Locale.ENGLISH).replaceAll("""\W+""", "-")
def nonEmpty(s: String, label: String) { def nonEmpty(s: String, label: String): Unit = require(s.trim.length > 0, label + " cannot be empty.")
require(s.trim.length > 0, label + " cannot be empty.")
}
def appendable(s: String) = if (s.isEmpty) "" else "_" + s def appendable(s: String) = if (s.isEmpty) "" else "_" + s
} }

View File

@ -54,7 +54,7 @@ object ErrorMessageAuthenticator {
} }
/** Installs the error message authenticator so we have nicer error messages when using java's URL for downloading. */ /** Installs the error message authenticator so we have nicer error messages when using java's URL for downloading. */
def install() { def install(): Unit = {
// Actually installs the error message authenticator. // Actually installs the error message authenticator.
def doInstall(original: Option[Authenticator]): Unit = def doInstall(original: Option[Authenticator]): Unit =
try Authenticator.setDefault(new ErrorMessageAuthenticator(original)) try Authenticator.setDefault(new ErrorMessageAuthenticator(original))