Update to latest sbt-houserules, formatting

This commit is contained in:
Martin Duhem 2015-09-16 14:57:00 +02:00
parent 8bf3873d3b
commit 699dcfdee5
24 changed files with 221 additions and 121 deletions

View File

@ -1,5 +1,6 @@
import Dependencies._
def baseVersion = "0.1.0"
def internalPath = file("internal")
def commonSettings: Seq[Setting[_]] = Seq(
@ -40,7 +41,6 @@ lazy val root = (project in file(".")).
settings(
inThisBuild(Seq(
organization := "org.scala-sbt",
version := "0.1.0-SNAPSHOT",
homepage := Some(url("https://github.com/sbt/librarymanagement")),
description := "Library management module for sbt",
licenses := List("BSD New" -> url("https://github.com/sbt/sbt/blob/0.13/LICENSE")),
@ -54,7 +54,8 @@ lazy val root = (project in file(".")).
bintrayReleaseOnPublish := false,
bintrayOrganization := Some("sbt"),
bintrayRepository := "maven-releases",
bintrayPackage := "librarymanagement"
bintrayPackage := "librarymanagement",
git.baseVersion := baseVersion
)),
commonSettings,
name := "LM Root",

View File

@ -49,13 +49,17 @@ private[sbt] object ConvertResolver {
private val signerNameField: Option[java.lang.reflect.Field] =
reflectiveLookup(_.getDeclaredField("signerName"))
private val putChecksumMethod: Option[java.lang.reflect.Method] =
reflectiveLookup(_.getDeclaredMethod("putChecksum",
reflectiveLookup(_.getDeclaredMethod(
"putChecksum",
classOf[IArtifact], classOf[File], classOf[String],
classOf[Boolean], classOf[String]))
classOf[Boolean], classOf[String]
))
private val putSignatureMethod: Option[java.lang.reflect.Method] =
reflectiveLookup(_.getDeclaredMethod("putSignature",
reflectiveLookup(_.getDeclaredMethod(
"putSignature",
classOf[IArtifact], classOf[File], classOf[String],
classOf[Boolean]))
classOf[Boolean]
))
}
/**
* The default behavior of ivy's overwrite flags ignores the fact that a lot of repositories
@ -93,7 +97,7 @@ private[sbt] object ConvertResolver {
if (signerName != null) {
putSignatureMethod match {
case None => ()
case Some(method) => method.invoke(artifact, src, dest, true: java.lang.Boolean) ; ()
case Some(method) => method.invoke(artifact, src, dest, true: java.lang.Boolean); ()
}
}
}

View File

@ -290,11 +290,13 @@ private[sbt] object IvySbt {
val delegate = new ivyint.SbtChainResolver(name + "-delegate", mapResolvers(rest), settings, updateOptions, log)
val prs = mapResolvers(projectResolvers)
// Here we construct a chain resolver which will FORCE looking at the project resolver first.
new ivyint.SbtChainResolver(name,
new ivyint.SbtChainResolver(
name,
prs :+ delegate,
settings,
UpdateOptions().withLatestSnapshots(false),
log)
log
)
}
}

View File

@ -32,7 +32,8 @@ final class UpdateConfiguration(val retrieve: Option[RetrieveConfiguration], val
private[sbt] def copy(
retrieve: Option[RetrieveConfiguration] = this.retrieve,
missingOk: Boolean = this.missingOk,
logging: UpdateLogging.Value = this.logging): UpdateConfiguration =
logging: UpdateLogging.Value = this.logging
): UpdateConfiguration =
new UpdateConfiguration(retrieve, missingOk, logging)
}
final class RetrieveConfiguration(val retrieveDirectory: File, val outputPattern: String, val sync: Boolean, val configurationsToRetrieve: Option[Set[Configuration]]) {
@ -45,7 +46,8 @@ final case class GetClassifiersConfiguration(module: GetClassifiersModule, exclu
final case class GetClassifiersModule(id: ModuleID, modules: Seq[ModuleID], configurations: Seq[Configuration], classifiers: Seq[String])
final class UnresolvedWarningConfiguration private[sbt] (
val modulePositions: Map[ModuleID, SourcePosition])
val modulePositions: Map[ModuleID, SourcePosition]
)
object UnresolvedWarningConfiguration {
def apply(): UnresolvedWarningConfiguration = apply(Map())
def apply(modulePositions: Map[ModuleID, SourcePosition]): UnresolvedWarningConfiguration =
@ -380,7 +382,8 @@ object IvyActions {
final class ResolveException(
val messages: Seq[String],
val failed: Seq[ModuleID],
val failedPaths: Map[ModuleID, Seq[ModuleID]]) extends RuntimeException(messages.mkString("\n")) {
val failedPaths: Map[ModuleID, Seq[ModuleID]]
) extends RuntimeException(messages.mkString("\n")) {
def this(messages: Seq[String], failed: Seq[ModuleID]) =
this(messages, failed, Map(failed map { m => m -> Nil }: _*))
}
@ -390,7 +393,8 @@ final class ResolveException(
*/
final class UnresolvedWarning private[sbt] (
val resolveException: ResolveException,
val failedPaths: Seq[Seq[(ModuleID, Option[SourcePosition])]])
val failedPaths: Seq[Seq[(ModuleID, Option[SourcePosition])]]
)
object UnresolvedWarning {
private[sbt] def apply(err: ResolveException, config: UnresolvedWarningConfiguration): UnresolvedWarning = {
def modulePosition(m0: ModuleID): Option[SourcePosition] =

View File

@ -21,9 +21,9 @@ sealed trait IvyConfiguration {
def updateOptions: UpdateOptions
}
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 checksums: Seq[String], val resolutionCacheDir: Option[File], val updateOptions: UpdateOptions,
val log: Logger) extends IvyConfiguration {
val moduleConfigurations: Seq[ModuleConfiguration], val localOnly: Boolean, val lock: Option[xsbti.GlobalLock],
val checksums: Seq[String], val resolutionCacheDir: Option[File], val updateOptions: UpdateOptions,
val log: Logger) extends IvyConfiguration {
@deprecated("Use the variant that accepts resolutionCacheDir and updateOptions.", "0.13.0")
def this(paths: IvyPaths, resolvers: Seq[Resolver], otherResolvers: Seq[Resolver],
moduleConfigurations: Seq[ModuleConfiguration], localOnly: Boolean, lock: Option[xsbti.GlobalLock],
@ -74,7 +74,7 @@ final class InlineIvyConfiguration(val paths: IvyPaths, val resolvers: Seq[Resol
}
}
final class ExternalIvyConfiguration(val baseDirectory: File, val uri: URI, val lock: Option[xsbti.GlobalLock],
val extraResolvers: Seq[Resolver], val updateOptions: UpdateOptions, val log: Logger) extends IvyConfiguration {
val extraResolvers: Seq[Resolver], val updateOptions: UpdateOptions, val log: Logger) extends IvyConfiguration {
@deprecated("Use the variant that accepts updateOptions.", "0.13.6")
def this(baseDirectory: File, uri: URI, lock: Option[xsbti.GlobalLock], extraResolvers: Seq[Resolver], log: Logger) =
this(baseDirectory, uri, lock, extraResolvers, UpdateOptions(), log)
@ -139,23 +139,26 @@ object InlineConfiguration {
explicitConfigurations
}
final class InlineConfigurationWithExcludes private[sbt] (val module: ModuleID,
val moduleInfo: ModuleInfo,
val dependencies: Seq[ModuleID],
val overrides: Set[ModuleID],
val excludes: Seq[SbtExclusionRule],
val ivyXML: NodeSeq,
val configurations: Seq[Configuration],
val defaultConfiguration: Option[Configuration],
val ivyScala: Option[IvyScala],
val validate: Boolean,
val conflictManager: ConflictManager) extends ModuleSettings {
final class InlineConfigurationWithExcludes private[sbt] (
val module: ModuleID,
val moduleInfo: ModuleInfo,
val dependencies: Seq[ModuleID],
val overrides: Set[ModuleID],
val excludes: Seq[SbtExclusionRule],
val ivyXML: NodeSeq,
val configurations: Seq[Configuration],
val defaultConfiguration: Option[Configuration],
val ivyScala: Option[IvyScala],
val validate: Boolean,
val conflictManager: ConflictManager
) extends ModuleSettings {
def withConfigurations(configurations: Seq[Configuration]) = copy(configurations = configurations)
def noScala = copy(ivyScala = None)
def withOverrides(overrides: Set[ModuleID]): ModuleSettings =
copy(overrides = overrides)
private[sbt] def copy(module: ModuleID = this.module,
private[sbt] def copy(
module: ModuleID = this.module,
moduleInfo: ModuleInfo = this.moduleInfo,
dependencies: Seq[ModuleID] = this.dependencies,
overrides: Set[ModuleID] = this.overrides,
@ -165,7 +168,8 @@ final class InlineConfigurationWithExcludes private[sbt] (val module: ModuleID,
defaultConfiguration: Option[Configuration] = this.defaultConfiguration,
ivyScala: Option[IvyScala] = this.ivyScala,
validate: Boolean = this.validate,
conflictManager: ConflictManager = this.conflictManager): InlineConfigurationWithExcludes =
conflictManager: ConflictManager = this.conflictManager
): InlineConfigurationWithExcludes =
InlineConfigurationWithExcludes(module, moduleInfo, dependencies, overrides, excludes, ivyXML,
configurations, defaultConfiguration, ivyScala, validate, conflictManager)
@ -206,7 +210,8 @@ final class InlineConfigurationWithExcludes private[sbt] (val module: ModuleID,
}
}
object InlineConfigurationWithExcludes {
def apply(module: ModuleID,
def apply(
module: ModuleID,
moduleInfo: ModuleInfo,
dependencies: Seq[ModuleID],
overrides: Set[ModuleID] = Set.empty,
@ -216,7 +221,8 @@ object InlineConfigurationWithExcludes {
defaultConfiguration: Option[Configuration] = None,
ivyScala: Option[IvyScala] = None,
validate: Boolean = false,
conflictManager: ConflictManager = ConflictManager.default): InlineConfigurationWithExcludes =
conflictManager: ConflictManager = ConflictManager.default
): InlineConfigurationWithExcludes =
new InlineConfigurationWithExcludes(module, moduleInfo, dependencies, overrides, excludes, ivyXML,
configurations, defaultConfiguration, ivyScala, validate, conflictManager)

View File

@ -93,10 +93,12 @@ object IvyRetrieve {
val branch = nonEmptyString(revId.getBranch)
val (status, publicationDate, resolver, artifactResolver) = dep.isLoaded match {
case true =>
(nonEmptyString(dep.getDescriptor.getStatus),
(
nonEmptyString(dep.getDescriptor.getStatus),
Some(new ju.Date(dep.getPublication)),
nonEmptyString(dep.getModuleRevision.getResolver.getName),
nonEmptyString(dep.getModuleRevision.getArtifactResolver.getName))
nonEmptyString(dep.getModuleRevision.getArtifactResolver.getName)
)
case _ => (None, None, None, None)
}
val (evicted, evictedData, evictedReason) = dep.isEvicted(confReport.getConfiguration) match {

View File

@ -39,7 +39,8 @@ private[sbt] object JsonUtil {
mr.evicted, mr.evictedData, mr.evictedReason,
mr.problem, mr.homepage, mr.extraAttributes,
mr.isDefault, mr.branch, mr.configurations, mr.licenses,
filterOutArtificialCallers(mr.callers))
filterOutArtificialCallers(mr.callers)
)
})
})
})

View File

@ -244,7 +244,8 @@ class MakePom(val log: Logger) {
log.warn(
s"""Translating intransitive dependency (${dependency.getDependencyId}) into pom.xml, but maven does not support intransitive dependencies.
| Please use exclusions instead so transitive dependencies will be correctly excluded in dependent projects.
""".stripMargin)
""".stripMargin
)
else ()
val artifacts = dependency.getAllDependencyArtifacts
val includeArtifacts = artifacts.filter(d => includeTypes(d.getType))
@ -372,7 +373,8 @@ class MakePom(val log: Logger) {
<exclusion>
<groupId>{ g }</groupId>
<artifactId>{ a }</artifactId>
</exclusion>)
</exclusion>
)
}
def makeRepositories(settings: IvySettings, includeAll: Boolean, filterRepositories: MavenRepository => Boolean) =

View File

@ -8,18 +8,23 @@ final class SbtExclusionRule(
val name: String,
val artifact: String,
val configurations: Seq[String],
val crossVersion: CrossVersion) {
val crossVersion: CrossVersion
) {
def copy(organization: String = this.organization,
def copy(
organization: String = this.organization,
name: String = this.name,
artifact: String = this.artifact,
configurations: Seq[String] = this.configurations,
crossVersion: CrossVersion = this.crossVersion): SbtExclusionRule =
SbtExclusionRule(organization = organization,
crossVersion: CrossVersion = this.crossVersion
): SbtExclusionRule =
SbtExclusionRule(
organization = organization,
name = name,
artifact = artifact,
configurations = configurations,
crossVersion = crossVersion)
crossVersion = crossVersion
)
}
object SbtExclusionRule {
@ -29,11 +34,13 @@ object SbtExclusionRule {
def apply(organization: String, name: String): SbtExclusionRule =
new SbtExclusionRule(organization, name, "*", Nil, CrossVersion.Disabled)
def apply(organization: String,
def apply(
organization: String,
name: String,
artifact: String,
configurations: Seq[String],
crossVersion: CrossVersion): SbtExclusionRule =
crossVersion: CrossVersion
): SbtExclusionRule =
new SbtExclusionRule(organization, name, artifact, configurations, crossVersion)
implicit def groupIdToExclusionRule(organization: GroupID): SbtExclusionRule =

View File

@ -44,7 +44,8 @@ final class GroupID private[sbt] (private[sbt] val groupID: String) {
final class GroupArtifactID private[sbt] (
private[sbt] val groupID: String,
private[sbt] val artifactID: String,
private[sbt] val crossVersion: CrossVersion) {
private[sbt] val crossVersion: CrossVersion
) {
def %(revision: String): ModuleID =
{
nonEmpty(revision, "Revision")

View File

@ -492,9 +492,11 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
breakLoops(loop)
// sort the all modules such that less called modules comes earlier
@tailrec def sortModules(cs: Vector[(String, String)],
@tailrec def sortModules(
cs: Vector[(String, String)],
acc: Vector[(String, String)], extra: Vector[(String, String)],
n: Int, guard: Int): Vector[(String, String)] =
n: Int, guard: Int
): Vector[(String, String)] =
{
// println(s"sortModules: $n / $guard")
val keys = cs.toSet
@ -522,8 +524,10 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
sortModules(cs.tail, acc, extra :+ cs.head, n + 1, guard)
} else sortModules(called, acc ++ notCalled, extra, 0, called.size * called.size + 1))
}
def resolveConflicts(cs: List[(String, String)],
allModules: Map[(String, String), Vector[OrganizationArtifactReport]]): List[OrganizationArtifactReport] =
def resolveConflicts(
cs: List[(String, String)],
allModules: Map[(String, String), Vector[OrganizationArtifactReport]]
): List[OrganizationArtifactReport] =
cs match {
case Nil => Nil
case (organization, name) :: rest =>

View File

@ -114,7 +114,8 @@ private[sbt] final class ErrorMessageAuthenticator(original: Option[Authenticato
getRequestingPort,
getRequestingProtocol,
getRequestingPrompt,
getRequestingScheme))
getRequestingScheme
))
finally Authenticator.setDefault(this)
}
originalAuthentication.orNull

View File

@ -23,7 +23,8 @@ private[sbt] case class SbtChainResolver(
resolvers: Seq[DependencyResolver],
settings: IvySettings,
updateOptions: UpdateOptions,
log: Logger) extends ChainResolver {
log: Logger
) extends ChainResolver {
override def equals(o: Any): Boolean = o match {
case o: SbtChainResolver =>
@ -139,7 +140,8 @@ private[sbt] case class SbtChainResolver(
else if (useLatest) temp map { x =>
(reparseModuleDescriptor(dd, data, resolver, x), resolver)
}
else temp map { x => (forcedRevision(x), resolver) })
else temp map { x => (forcedRevision(x), resolver) }
)
} catch {
case ex: Exception =>
Message.verbose("problem occurred while resolving " + dd + " with " + resolver

View File

@ -79,7 +79,7 @@ object CrossVersion {
/**
* Cross-versions a module with the result of applying `remapVersion` to the full version
* (typically the full Scala version). See also [[sbt.CrossVersion.Full]].
* (typically the full Scala version). See also [[sbt.librarymanagement.CrossVersion.Full]].
*/
def fullMapped(remapVersion: String => String): CrossVersion = new Full(remapVersion)
@ -88,7 +88,7 @@ object CrossVersion {
/**
* Cross-versions a module with the result of applying `remapVersion` to the binary version
* (typically the binary Scala version). See also [[sbt.CrossVersion.Binary]].
* (typically the binary Scala version). See also [[sbt.librarymanagement.CrossVersion.Binary]].
*/
def binaryMapped(remapVersion: String => String): CrossVersion = new Binary(remapVersion)
@ -99,7 +99,7 @@ object CrossVersion {
/**
* Construct a cross-versioning function given cross-versioning configuration `cross`,
* full version `fullVersion` and binary version `binaryVersion`. The behavior of the
* constructed function is as documented for the [[sbt.CrossVersion]] datatypes.
* constructed function is as documented for the [[sbt.librarymanagement.CrossVersion]] datatypes.
*/
def apply(cross: CrossVersion, fullVersion: String, binaryVersion: String): Option[String => String] =
cross match {
@ -191,13 +191,13 @@ object CrossVersion {
/**
* Computes the binary Scala version from the `full` version.
* Full Scala versions earlier than [[sbt.CrossVersion.TransitionScalaVersion]] are returned as is.
* Full Scala versions earlier than [[sbt.librarymanagement.CrossVersion.TransitionScalaVersion]] are returned as is.
*/
def binaryScalaVersion(full: String): String = CrossVersionUtil.binaryScalaVersion(full)
/**
* Computes the binary sbt version from the `full` version.
* Full sbt versions earlier than [[sbt.CrossVersion.TransitionSbtVersion]] are returned as is.
* Full sbt versions earlier than [[sbt.librarymanagement.CrossVersion.TransitionSbtVersion]] are returned as is.
*/
def binarySbtVersion(full: String): String = CrossVersionUtil.binarySbtVersion(full)

View File

@ -14,7 +14,8 @@ final class EvictionWarningOptions private[sbt] (
val warnTransitiveEvictions: Boolean,
val infoAllEvictions: Boolean,
val showCallers: Boolean,
val guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[IvyScala]), Boolean]) {
val guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[IvyScala]), Boolean]
) {
private[sbt] def configStrings = configurations map { _.name }
def withConfigurations(configurations: Seq[Configuration]): EvictionWarningOptions =
@ -32,20 +33,24 @@ final class EvictionWarningOptions private[sbt] (
def withGuessCompatible(guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[IvyScala]), Boolean]): EvictionWarningOptions =
copy(guessCompatible = guessCompatible)
private[sbt] def copy(configurations: Seq[Configuration] = configurations,
private[sbt] def copy(
configurations: Seq[Configuration] = configurations,
warnScalaVersionEviction: Boolean = warnScalaVersionEviction,
warnDirectEvictions: Boolean = warnDirectEvictions,
warnTransitiveEvictions: Boolean = warnTransitiveEvictions,
infoAllEvictions: Boolean = infoAllEvictions,
showCallers: Boolean = showCallers,
guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[IvyScala]), Boolean] = guessCompatible): EvictionWarningOptions =
new EvictionWarningOptions(configurations = configurations,
guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[IvyScala]), Boolean] = guessCompatible
): EvictionWarningOptions =
new EvictionWarningOptions(
configurations = configurations,
warnScalaVersionEviction = warnScalaVersionEviction,
warnDirectEvictions = warnDirectEvictions,
warnTransitiveEvictions = warnTransitiveEvictions,
infoAllEvictions = infoAllEvictions,
showCallers = showCallers,
guessCompatible = guessCompatible)
guessCompatible = guessCompatible
)
}
object EvictionWarningOptions {
@ -85,7 +90,8 @@ final class EvictionPair private[sbt] (
val winner: Option[ModuleReport],
val evicteds: Seq[ModuleReport],
val includesDirect: Boolean,
val showCallers: Boolean) {
val showCallers: Boolean
) {
override def toString: String =
EvictionPair.evictionPairLines.showLines(this).mkString
override def equals(o: Any): Boolean = o match {
@ -125,7 +131,8 @@ final class EvictionWarning private[sbt] (
val scalaEvictions: Seq[EvictionPair],
val directEvictions: Seq[EvictionPair],
val transitiveEvictions: Seq[EvictionPair],
val allEvictions: Seq[EvictionPair]) {
val allEvictions: Seq[EvictionPair]
) {
def reportedEvictions: Seq[EvictionPair] = scalaEvictions ++ directEvictions ++ transitiveEvictions
private[sbt] def infoAllTheThings: List[String] = EvictionWarning.infoAllTheThings(this)
}

View File

@ -21,7 +21,8 @@ object ScalaArtifacts {
private[sbt] def toolDependencies(org: String, version: String): Seq[ModuleID] = Seq(
scalaToolDependency(org, ScalaArtifacts.CompilerID, version),
scalaToolDependency(org, ScalaArtifacts.LibraryID, version))
scalaToolDependency(org, ScalaArtifacts.LibraryID, version)
)
private[this] def scalaToolDependency(org: String, id: String, version: String): ModuleID =
ModuleID(org, id, version, Some(Configurations.ScalaTool.name + "->default,optional(default)"))
}

View File

@ -22,18 +22,23 @@ final class UpdateOptions private[sbt] (
/** If set to true, use cached resolution. */
val cachedResolution: Boolean,
/** Extention point for an alternative resolver converter. */
val resolverConverter: UpdateOptions.ResolverConverter) {
val resolverConverter: UpdateOptions.ResolverConverter
) {
def withCircularDependencyLevel(circularDependencyLevel: CircularDependencyLevel): UpdateOptions =
copy(circularDependencyLevel = circularDependencyLevel)
def withLatestSnapshots(latestSnapshots: Boolean): UpdateOptions =
copy(latestSnapshots = latestSnapshots)
@deprecated("Use withCachedResolution instead.", "0.13.7")
def withConsolidatedResolution(consolidatedResolution: Boolean): UpdateOptions =
copy(consolidatedResolution = consolidatedResolution,
cachedResolution = consolidatedResolution)
copy(
consolidatedResolution = consolidatedResolution,
cachedResolution = consolidatedResolution
)
def withCachedResolution(cachedResoluton: Boolean): UpdateOptions =
copy(cachedResolution = cachedResoluton,
consolidatedResolution = cachedResolution)
copy(
cachedResolution = cachedResoluton,
consolidatedResolution = cachedResolution
)
/** Extention point for an alternative resolver converter. */
def withResolverConverter(resolverConverter: UpdateOptions.ResolverConverter): UpdateOptions =
copy(resolverConverter = resolverConverter)
@ -43,12 +48,15 @@ final class UpdateOptions private[sbt] (
latestSnapshots: Boolean = this.latestSnapshots,
consolidatedResolution: Boolean = this.consolidatedResolution,
cachedResolution: Boolean = this.cachedResolution,
resolverConverter: UpdateOptions.ResolverConverter = this.resolverConverter): UpdateOptions =
new UpdateOptions(circularDependencyLevel,
resolverConverter: UpdateOptions.ResolverConverter = this.resolverConverter
): UpdateOptions =
new UpdateOptions(
circularDependencyLevel,
latestSnapshots,
consolidatedResolution,
cachedResolution,
resolverConverter)
resolverConverter
)
override def equals(o: Any): Boolean = o match {
case o: UpdateOptions =>
@ -79,5 +87,6 @@ object UpdateOptions {
latestSnapshots = false,
consolidatedResolution = false,
cachedResolution = false,
resolverConverter = PartialFunction.empty)
resolverConverter = PartialFunction.empty
)
}

View File

@ -19,7 +19,8 @@ import sbt.internal.librarymanagement.{ DependencyFilter, ConfigurationFilter, M
final class ConfigurationReport(
val configuration: String,
val modules: Seq[ModuleReport],
val details: Seq[OrganizationArtifactReport]) {
val details: Seq[OrganizationArtifactReport]
) {
def evicted: Seq[ModuleID] =
details flatMap (_.modules) filter (_.evicted) map (_.module)
@ -56,7 +57,8 @@ object ConfigurationReport {
final class OrganizationArtifactReport private[sbt] (
val organization: String,
val name: String,
val modules: Seq[ModuleReport]) {
val modules: Seq[ModuleReport]
) {
override def toString: String = {
val details = modules map { _.detailReport }
s"\t$organization:$name\n${details.mkString}\n"
@ -94,7 +96,8 @@ final class ModuleReport(
val branch: Option[String],
val configurations: Seq[String],
val licenses: Seq[(String, Option[String])],
val callers: Seq[Caller]) {
val callers: Seq[Caller]
) {
private[this] lazy val arts: Seq[String] = artifacts.map(_.toString) ++ missingArtifacts.map(art => "(MISSING) " + art)
override def toString: String = {
@ -113,20 +116,28 @@ final class ModuleReport(
reportStr("evictedReason", evictedReason) +
reportStr("problem", problem) +
reportStr("homepage", homepage) +
reportStr("textraAttributes",
reportStr(
"textraAttributes",
if (extraAttributes.isEmpty) None
else { Some(extraAttributes.toString) }) +
else { Some(extraAttributes.toString) }
) +
reportStr("isDefault", isDefault map { _.toString }) +
reportStr("branch", branch) +
reportStr("configurations",
reportStr(
"configurations",
if (configurations.isEmpty) None
else { Some(configurations.mkString(", ")) }) +
reportStr("licenses",
else { Some(configurations.mkString(", ")) }
) +
reportStr(
"licenses",
if (licenses.isEmpty) None
else { Some(licenses.mkString(", ")) }) +
reportStr("callers",
else { Some(licenses.mkString(", ")) }
) +
reportStr(
"callers",
if (callers.isEmpty) None
else { Some(callers.mkString(", ")) })
else { Some(callers.mkString(", ")) }
)
private[sbt] def reportStr(key: String, value: Option[String]): String =
value map { x => s"\t\t\t$key: $x\n" } getOrElse ""
@ -151,7 +162,8 @@ final class ModuleReport(
branch: Option[String] = branch,
configurations: Seq[String] = configurations,
licenses: Seq[(String, Option[String])] = licenses,
callers: Seq[Caller] = callers): ModuleReport =
callers: Seq[Caller] = callers
): ModuleReport =
new ModuleReport(module, artifacts, missingArtifacts, status, publicationDate, resolver, artifactResolver,
evicted, evictedData, evictedReason, problem, homepage, extraAttributes, isDefault, branch, configurations, licenses, callers)
}
@ -170,7 +182,8 @@ final class Caller(
val isForceDependency: Boolean,
val isChangingDependency: Boolean,
val isTransitiveDependency: Boolean,
val isDirectlyForceDependency: Boolean) {
val isDirectlyForceDependency: Boolean
) {
override def toString: String =
s"$caller"
}
@ -207,10 +220,12 @@ final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[Con
def allConfigurations: Seq[String] = configurations.map(_.configuration)
private[sbt] def withStats(us: UpdateStats): UpdateReport =
new UpdateReport(this.cachedDescriptor,
new UpdateReport(
this.cachedDescriptor,
this.configurations,
us,
this.stamps)
this.stamps
)
}
object UpdateReport {
@ -248,14 +263,16 @@ object UpdateReport {
moduleReportMap { (configuration, modReport) =>
modReport.copy(
artifacts = modReport.artifacts filter { case (art, file) => f(configuration, modReport.module, art) },
missingArtifacts = modReport.missingArtifacts filter { art => f(configuration, modReport.module, art) })
missingArtifacts = modReport.missingArtifacts filter { art => f(configuration, modReport.module, art) }
)
}
def substitute(f: (String, ModuleID, Seq[(Artifact, File)]) => Seq[(Artifact, File)]): UpdateReport =
moduleReportMap { (configuration, modReport) =>
val newArtifacts = f(configuration, modReport.module, modReport.artifacts)
modReport.copy(
artifacts = f(configuration, modReport.module, modReport.artifacts),
missingArtifacts = Nil)
missingArtifacts = Nil
)
}
def toSeq: Seq[(String, ModuleID, Artifact, File)] =
@ -267,7 +284,8 @@ object UpdateReport {
def addMissing(f: ModuleID => Seq[Artifact]): UpdateReport =
moduleReportMap { (configuration, modReport) =>
modReport.copy(
missingArtifacts = (modReport.missingArtifacts ++ f(modReport.module)).distinct)
missingArtifacts = (modReport.missingArtifacts ++ f(modReport.module)).distinct
)
}
def moduleReportMap(f: (String, ModuleReport) => ModuleReport): UpdateReport =
@ -338,10 +356,12 @@ object UpdateReport {
final class UpdateStats(val resolveTime: Long, val downloadTime: Long, val downloadSize: Long, val cached: Boolean) {
override def toString = Seq("Resolve time: " + resolveTime + " ms", "Download time: " + downloadTime + " ms", "Download size: " + downloadSize + " bytes").mkString(", ")
private[sbt] def withCached(c: Boolean): UpdateStats =
new UpdateStats(resolveTime = this.resolveTime,
new UpdateStats(
resolveTime = this.resolveTime,
downloadTime = this.downloadTime,
downloadSize = this.downloadSize,
cached = c)
cached = c
)
}
object UpdateStats {
implicit val pickler: Pickler[UpdateStats] with Unpickler[UpdateStats] = PicklerUnpickler.generate[UpdateStats]

View File

@ -3,7 +3,8 @@ package sbt.librarymanagement
final class VersionNumber private[sbt] (
val numbers: Seq[Long],
val tags: Seq[String],
val extras: Seq[String]) {
val extras: Seq[String]
) {
def _1: Option[Long] = get(0)
def _2: Option[Long] = get(1)
def _3: Option[Long] = get(2)

View File

@ -29,7 +29,8 @@ trait BaseIvySpecification extends UnitSpec {
configurations = Nil,
checkExplicit = true,
filterImplicit = false,
overrideScalaVersion = false)
overrideScalaVersion = false
)
}
val moduleSetting: ModuleSettings = InlineConfiguration(
@ -37,7 +38,8 @@ trait BaseIvySpecification extends UnitSpec {
moduleInfo = ModuleInfo("foo"),
dependencies = deps,
configurations = configurations,
ivyScala = ivyScala)
ivyScala = ivyScala
)
val ivySbt = new IvySbt(mkIvyConfiguration(uo))
new ivySbt.Module(moduleSetting)
}
@ -81,7 +83,8 @@ trait BaseIvySpecification extends UnitSpec {
artifacts = artifacts,
checksums = Seq(),
logging = UpdateLogging.Full,
overwrite = true)
overwrite = true
)
}
def ivyPublish(module: IvySbt#Module, config: PublishConfiguration) = {

View File

@ -8,8 +8,10 @@ class CachedResolutionSpec extends BaseIvySpecification {
"Resolving the same module twice" should "work" in {
cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")),
Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true))
val m = module(
ModuleID("com.example", "foo", "0.1.0", Some("compile")),
Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true)
)
val report = ivyUpdate(m)
cleanCachedResolutionCache(m)
val report2 = ivyUpdate(m)
@ -22,8 +24,10 @@ class CachedResolutionSpec extends BaseIvySpecification {
"Resolving the unsolvable module should" should "not work" in {
// log.setLevel(Level.Debug)
val m = module(ModuleID("com.example", "foo", "0.2.0", Some("compile")),
Seq(mavenCayennePlugin302), Some("2.10.2"), UpdateOptions().withCachedResolution(true))
val m = module(
ModuleID("com.example", "foo", "0.2.0", Some("compile")),
Seq(mavenCayennePlugin302), Some("2.10.2"), UpdateOptions().withCachedResolution(true)
)
ivyUpdateEither(m) match {
case Right(_) => sys.error("this should've failed")
case Left(uw) =>
@ -47,9 +51,11 @@ class CachedResolutionSpec extends BaseIvySpecification {
"Resolving a module with a pseudo-conflict" should "work" in {
// log.setLevel(Level.Debug)
cleanIvyCache()
val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")),
val m = module(
ModuleID("com.example", "foo", "0.3.0", Some("compile")),
Seq(avro177, dataAvro1940, netty320),
Some("2.10.2"), UpdateOptions().withCachedResolution(true))
Some("2.10.2"), UpdateOptions().withCachedResolution(true)
)
// first resolution creates the minigraph
val report0 = ivyUpdate(m)
cleanCachedResolutionCache(m)

View File

@ -74,21 +74,25 @@ class EvictionWarningSpec extends BaseIvySpecification {
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines shouldBe
List("Scala version was updated by one of library dependencies:",
List(
"Scala version was updated by one of library dependencies:",
"\t* org.scala-lang:scala-library:2.10.2 -> 2.10.3",
"To force scalaVersion, add the following:",
"\tivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }",
"Run 'evicted' to see detailed eviction warnings")
"Run 'evicted' to see detailed eviction warnings"
)
}
def scalaVersionWarn4() = {
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withShowCallers(true), report, log).lines shouldBe
List("Scala version was updated by one of library dependencies:",
List(
"Scala version was updated by one of library dependencies:",
"\t* org.scala-lang:scala-library:2.10.2 -> 2.10.3 (caller: com.typesafe.akka:akka-actor_2.10:2.3.0, com.example:foo:0.1.0)",
"To force scalaVersion, add the following:",
"\tivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }")
"\tivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }"
)
}
def javaLibDirectDeps = Seq(commonsIo14, commonsIo24)
@ -109,19 +113,23 @@ class EvictionWarningSpec extends BaseIvySpecification {
val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3"))
val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.",
List(
"There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:",
"\t* commons-io:commons-io:1.4 -> 2.4",
"Run 'evicted' to see detailed eviction warnings")
"Run 'evicted' to see detailed eviction warnings"
)
}
def javaLibWarn4() = {
val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3"))
val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withShowCallers(true), report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.",
List(
"There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:",
"\t* commons-io:commons-io:1.4 -> 2.4 (caller: com.example:foo:0.1.0)")
"\t* commons-io:commons-io:1.4 -> 2.4 (caller: com.example:foo:0.1.0)"
)
}
def javaLibNoWarn1() = {
@ -156,9 +164,11 @@ class EvictionWarningSpec extends BaseIvySpecification {
val m = module(defaultModuleId, javaLibTransitiveDeps, Some("2.10.3"))
val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true).withShowCallers(true), report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.",
List(
"There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:",
"\t* commons-io:commons-io:1.4 -> 2.4 (caller: ca.gobits.bnf:bnfparser:1.0, net.databinder:unfiltered-uploads_2.10:0.8.0)")
"\t* commons-io:commons-io:1.4 -> 2.4 (caller: ca.gobits.bnf:bnfparser:1.0, net.databinder:unfiltered-uploads_2.10:0.8.0)"
)
}
def scalaLibWarn1() = {
@ -173,10 +183,12 @@ class EvictionWarningSpec extends BaseIvySpecification {
val m = module(defaultModuleId, deps, Some("2.10.4"))
val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions, report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.",
List(
"There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:",
"\t* com.typesafe.akka:akka-actor_2.10:2.1.4 -> 2.3.4",
"Run 'evicted' to see detailed eviction warnings")
"Run 'evicted' to see detailed eviction warnings"
)
}
def scalaLibNoWarn1() = {
@ -211,8 +223,10 @@ class EvictionWarningSpec extends BaseIvySpecification {
val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4"))
val report = ivyUpdate(m)
EvictionWarning(m, defaultOptions.withWarnTransitiveEvictions(true).withShowCallers(true), report, log).lines shouldBe
List("There may be incompatibilities among your library dependencies.",
List(
"There may be incompatibilities among your library dependencies.",
"Here are some of the libraries that were evicted:",
"\t* com.typesafe.akka:akka-actor_2.10:2.1.4 -> 2.3.4 (caller: com.typesafe.akka:akka-remote_2.10:2.3.4, org.w3:banana-sesame_2.10:0.4, org.w3:banana-rdf_2.10:0.4)")
"\t* com.typesafe.akka:akka-actor_2.10:2.1.4 -> 2.3.4 (caller: com.typesafe.akka:akka-remote_2.10:2.3.4, org.w3:banana-sesame_2.10:0.4, org.w3:banana-rdf_2.10:0.4)"
)
}
}

View File

@ -7,8 +7,10 @@ import sbt.librarymanagement._
class InconsistentDuplicateSpec extends UnitSpec {
"Duplicate with different version" should "be warned" in {
IvySbt.inconsistentDuplicateWarning(Seq(akkaActor214, akkaActor230)) shouldBe
List("Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:",
" * com.typesafe.akka:akka-actor:(2.1.4, 2.3.0)")
List(
"Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:",
" * com.typesafe.akka:akka-actor:(2.1.4, 2.3.0)"
)
}
"Duplicate with same version" should "not be warned" in {

View File

@ -1 +1 @@
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.1.0")
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.2.1")