diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala index d6ce9b20d..8d646ee65 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala @@ -20,6 +20,7 @@ import sbt.io.{ IO, PathFinder } import sbt.util.Logger import sbt.internal.util.{ ShowLines, SourcePosition, LinePosition, RangePosition, LineRange } import sbt.librarymanagement._ +import sbt.internal.librarymanagement.syntax._ final class DeliverConfiguration(val deliverIvyPattern: String, val status: String, val configurations: Option[Seq[Configuration]], val logging: UpdateLogging.Value) final class PublishConfiguration(val ivyFile: Option[File], val resolverName: String, val artifacts: Map[Artifact, File], val checksums: Seq[String], val logging: UpdateLogging.Value, diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala index 196e0e1ae..765af3ab1 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala @@ -15,6 +15,7 @@ import resolve.{ IvyNode, IvyNodeCallers } import IvyNodeCallers.{ Caller => IvyCaller } import ivyint.SbtDefaultDependencyDescriptor import sbt.librarymanagement._ +import sbt.internal.librarymanagement.syntax._ object IvyRetrieve { def reports(report: ResolveReport): Seq[ConfigurationResolveReport] = diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RichUpdateReport.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RichUpdateReport.scala new file mode 100644 index 000000000..61675fd2d --- /dev/null +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RichUpdateReport.scala @@ -0,0 +1,75 @@ +package sbt +package internal +package librarymanagement + +import java.io.File +import java.net.URL +import sbt.librarymanagement._ + +/** Provides extra methods for filtering the contents of an `UpdateReport` and for obtaining references to a selected subset of the underlying files. */ +final class RichUpdateReport(report: UpdateReport) { + def recomputeStamps(): UpdateReport = + { + val files = report.cachedDescriptor +: allFiles + val stamps = files.map(f => (f, f.lastModified)).toMap + new UpdateReport(report.cachedDescriptor, report.configurations, report.stats, stamps) + } + + import DependencyFilter._ + + /** Obtains all successfully retrieved files in all configurations and modules. */ + def allFiles: Seq[File] = matching(DependencyFilter.allPass) + + /** Obtains all successfully retrieved files in configurations, modules, and artifacts matching the specified filter. */ + def matching(f: DependencyFilter): Seq[File] = select0(f).distinct + + /** Obtains all successfully retrieved files matching all provided filters. An unspecified argument matches all files. */ + def select(configuration: ConfigurationFilter = configurationFilter(), module: ModuleFilter = moduleFilter(), artifact: ArtifactFilter = artifactFilter()): Seq[File] = + matching(DependencyFilter.make(configuration, module, artifact)) + + private[this] def select0(f: DependencyFilter): Seq[File] = + for (cReport <- report.configurations; mReport <- cReport.modules; (artifact, file) <- mReport.artifacts if f(cReport.configuration, mReport.module, artifact)) yield { + if (file == null) sys.error("Null file: conf=" + cReport.configuration + ", module=" + mReport.module + ", art: " + artifact) + file + } + + /** Constructs a new report that only contains files matching the specified filter.*/ + private[sbt] def filter(f: DependencyFilter): 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) } + ) + } + 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 + ) + } + + def toSeq: Seq[(String, ModuleID, Artifact, File)] = + for (confReport <- report.configurations; modReport <- confReport.modules; (artifact, file) <- modReport.artifacts) yield (confReport.configuration, modReport.module, artifact, file) + + def allMissing: Seq[(String, ModuleID, Artifact)] = + for (confReport <- report.configurations; modReport <- confReport.modules; artifact <- modReport.missingArtifacts) yield (confReport.configuration, modReport.module, artifact) + + def addMissing(f: ModuleID => Seq[Artifact]): UpdateReport = + moduleReportMap { (configuration, modReport) => + modReport.copy( + missingArtifacts = (modReport.missingArtifacts ++ f(modReport.module)).distinct + ) + } + + def moduleReportMap(f: (String, ModuleReport) => ModuleReport): UpdateReport = + { + val newConfigurations = report.configurations.map { confReport => + import confReport._ + val newModules = modules map { modReport => f(configuration, modReport) } + new ConfigurationReport(configuration, newModules, details) + } + new UpdateReport(report.cachedDescriptor, newConfigurations, report.stats, report.stamps) + } +} diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala index 4a8a8094e..c566fea30 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala @@ -25,6 +25,7 @@ import sbt.io.{ DirectoryFilter, Hash, IO, Path } import sbt.util.Logger import sbt.librarymanagement._ import Configurations.{ System => _, _ } +import sbt.internal.librarymanagement.syntax._ private[sbt] object CachedResolutionResolveCache { def createID(organization: String, name: String, revision: String) = diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/syntax.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/syntax.scala new file mode 100644 index 000000000..4ddc5d243 --- /dev/null +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/syntax.scala @@ -0,0 +1,10 @@ +package sbt +package internal +package librarymanagement + +import sbt.librarymanagement._ + +object syntax { + implicit def richUpateReport(ur: UpdateReport): RichUpdateReport = + new RichUpdateReport(ur) +} diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateOptions.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateOptions.scala index 47ab13507..be2ad412f 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateOptions.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateOptions.scala @@ -13,15 +13,15 @@ import sbt.util.Logger * See also UpdateConfiguration in IvyActions.scala. */ final class UpdateOptions private[sbt] ( - /** If set to CircularDependencyLevel.Error, halt the dependency resolution. */ + // If set to CircularDependencyLevel.Error, halt the dependency resolution. val circularDependencyLevel: CircularDependencyLevel, - /** If set to true, check all resolvers for snapshots. */ + // If set to true, check all resolvers for snapshots. val latestSnapshots: Boolean, - /** If set to true, use consolidated resolution. */ + // If set to true, use consolidated resolution. val consolidatedResolution: Boolean, - /** If set to true, use cached resolution. */ + // If set to true, use cached resolution. val cachedResolution: Boolean, - /** Extention point for an alternative resolver converter. */ + // Extention point for an alternative resolver converter. val resolverConverter: UpdateOptions.ResolverConverter ) { def withCircularDependencyLevel(circularDependencyLevel: CircularDependencyLevel): UpdateOptions = diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReport.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReport.scala index c51617dee..88603454d 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReport.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReport.scala @@ -250,76 +250,6 @@ final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[Con } object UpdateReport { - implicit def richUpdateReport(report: UpdateReport): RichUpdateReport = new RichUpdateReport(report) - - /** Provides extra methods for filtering the contents of an `UpdateReport` and for obtaining references to a selected subset of the underlying files. */ - final class RichUpdateReport(report: UpdateReport) { - def recomputeStamps(): UpdateReport = - { - val files = report.cachedDescriptor +: allFiles - val stamps = files.map(f => (f, f.lastModified)).toMap - new UpdateReport(report.cachedDescriptor, report.configurations, report.stats, stamps) - } - - import DependencyFilter._ - - /** Obtains all successfully retrieved files in all configurations and modules. */ - def allFiles: Seq[File] = matching(DependencyFilter.allPass) - - /** Obtains all successfully retrieved files in configurations, modules, and artifacts matching the specified filter. */ - private[sbt] def matching(f: DependencyFilter): Seq[File] = select0(f).distinct - - /** Obtains all successfully retrieved files matching all provided filters. An unspecified argument matches all files. */ - private[sbt] def select(configuration: ConfigurationFilter = configurationFilter(), module: ModuleFilter = moduleFilter(), artifact: ArtifactFilter = artifactFilter()): Seq[File] = - matching(DependencyFilter.make(configuration, module, artifact)) - - private[this] def select0(f: DependencyFilter): Seq[File] = - for (cReport <- report.configurations; mReport <- cReport.modules; (artifact, file) <- mReport.artifacts if f(cReport.configuration, mReport.module, artifact)) yield { - if (file == null) sys.error("Null file: conf=" + cReport.configuration + ", module=" + mReport.module + ", art: " + artifact) - file - } - - /** Constructs a new report that only contains files matching the specified filter.*/ - private[sbt] def filter(f: DependencyFilter): 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) } - ) - } - 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 - ) - } - - def toSeq: Seq[(String, ModuleID, Artifact, File)] = - for (confReport <- report.configurations; modReport <- confReport.modules; (artifact, file) <- modReport.artifacts) yield (confReport.configuration, modReport.module, artifact, file) - - def allMissing: Seq[(String, ModuleID, Artifact)] = - for (confReport <- report.configurations; modReport <- confReport.modules; artifact <- modReport.missingArtifacts) yield (confReport.configuration, modReport.module, artifact) - - def addMissing(f: ModuleID => Seq[Artifact]): UpdateReport = - moduleReportMap { (configuration, modReport) => - modReport.copy( - missingArtifacts = (modReport.missingArtifacts ++ f(modReport.module)).distinct - ) - } - - def moduleReportMap(f: (String, ModuleReport) => ModuleReport): UpdateReport = - { - val newConfigurations = report.configurations.map { confReport => - import confReport._ - val newModules = modules map { modReport => f(configuration, modReport) } - new ConfigurationReport(configuration, newModules, details) - } - new UpdateReport(report.cachedDescriptor, newConfigurations, report.stats, report.stamps) - } - } - private val vectorConfigurationReportPickler = implicitly[Pickler[Vector[ConfigurationReport]]] private val vectorConfigurationReportUnpickler = implicitly[Unpickler[Vector[ConfigurationReport]]] private val updateStatsPickler = implicitly[Pickler[UpdateStats]] diff --git a/project/Dependencies.scala b/project/Dependencies.scala index ee5217690..f07eb3e1d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -5,7 +5,7 @@ object Dependencies { lazy val scala210 = "2.10.5" lazy val scala211 = "2.11.7" - val utilVersion = "0.1.0-M3" + val utilVersion = "0.1.0-M5" val ioVersion = "1.0.0-M3" lazy val sbtIO = "org.scala-sbt" %% "io" % ioVersion lazy val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion