mirror of https://github.com/sbt/sbt.git
Merge pull request #9 from sbt/wip/richupdatereport
Split RichUpdateReport into internal
This commit is contained in:
commit
40b7ed8020
|
|
@ -20,6 +20,7 @@ import sbt.io.{ IO, PathFinder }
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
import sbt.internal.util.{ ShowLines, SourcePosition, LinePosition, RangePosition, LineRange }
|
import sbt.internal.util.{ ShowLines, SourcePosition, LinePosition, RangePosition, LineRange }
|
||||||
import sbt.librarymanagement._
|
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 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,
|
final class PublishConfiguration(val ivyFile: Option[File], val resolverName: String, val artifacts: Map[Artifact, File], val checksums: Seq[String], val logging: UpdateLogging.Value,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import resolve.{ IvyNode, IvyNodeCallers }
|
||||||
import IvyNodeCallers.{ Caller => IvyCaller }
|
import IvyNodeCallers.{ Caller => IvyCaller }
|
||||||
import ivyint.SbtDefaultDependencyDescriptor
|
import ivyint.SbtDefaultDependencyDescriptor
|
||||||
import sbt.librarymanagement._
|
import sbt.librarymanagement._
|
||||||
|
import sbt.internal.librarymanagement.syntax._
|
||||||
|
|
||||||
object IvyRetrieve {
|
object IvyRetrieve {
|
||||||
def reports(report: ResolveReport): Seq[ConfigurationResolveReport] =
|
def reports(report: ResolveReport): Seq[ConfigurationResolveReport] =
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,6 +25,7 @@ import sbt.io.{ DirectoryFilter, Hash, IO, Path }
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
import sbt.librarymanagement._
|
import sbt.librarymanagement._
|
||||||
import Configurations.{ System => _, _ }
|
import Configurations.{ System => _, _ }
|
||||||
|
import sbt.internal.librarymanagement.syntax._
|
||||||
|
|
||||||
private[sbt] object CachedResolutionResolveCache {
|
private[sbt] object CachedResolutionResolveCache {
|
||||||
def createID(organization: String, name: String, revision: String) =
|
def createID(organization: String, name: String, revision: String) =
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package sbt
|
||||||
|
package internal
|
||||||
|
package librarymanagement
|
||||||
|
|
||||||
|
import sbt.librarymanagement._
|
||||||
|
|
||||||
|
object syntax {
|
||||||
|
implicit def richUpateReport(ur: UpdateReport): RichUpdateReport =
|
||||||
|
new RichUpdateReport(ur)
|
||||||
|
}
|
||||||
|
|
@ -13,15 +13,15 @@ import sbt.util.Logger
|
||||||
* See also UpdateConfiguration in IvyActions.scala.
|
* See also UpdateConfiguration in IvyActions.scala.
|
||||||
*/
|
*/
|
||||||
final class UpdateOptions private[sbt] (
|
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,
|
val circularDependencyLevel: CircularDependencyLevel,
|
||||||
/** If set to true, check all resolvers for snapshots. */
|
// If set to true, check all resolvers for snapshots.
|
||||||
val latestSnapshots: Boolean,
|
val latestSnapshots: Boolean,
|
||||||
/** If set to true, use consolidated resolution. */
|
// If set to true, use consolidated resolution.
|
||||||
val consolidatedResolution: Boolean,
|
val consolidatedResolution: Boolean,
|
||||||
/** If set to true, use cached resolution. */
|
// If set to true, use cached resolution.
|
||||||
val cachedResolution: Boolean,
|
val cachedResolution: Boolean,
|
||||||
/** Extention point for an alternative resolver converter. */
|
// Extention point for an alternative resolver converter.
|
||||||
val resolverConverter: UpdateOptions.ResolverConverter
|
val resolverConverter: UpdateOptions.ResolverConverter
|
||||||
) {
|
) {
|
||||||
def withCircularDependencyLevel(circularDependencyLevel: CircularDependencyLevel): UpdateOptions =
|
def withCircularDependencyLevel(circularDependencyLevel: CircularDependencyLevel): UpdateOptions =
|
||||||
|
|
|
||||||
|
|
@ -250,76 +250,6 @@ final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[Con
|
||||||
}
|
}
|
||||||
|
|
||||||
object UpdateReport {
|
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 vectorConfigurationReportPickler = implicitly[Pickler[Vector[ConfigurationReport]]]
|
||||||
private val vectorConfigurationReportUnpickler = implicitly[Unpickler[Vector[ConfigurationReport]]]
|
private val vectorConfigurationReportUnpickler = implicitly[Unpickler[Vector[ConfigurationReport]]]
|
||||||
private val updateStatsPickler = implicitly[Pickler[UpdateStats]]
|
private val updateStatsPickler = implicitly[Pickler[UpdateStats]]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ object Dependencies {
|
||||||
lazy val scala210 = "2.10.5"
|
lazy val scala210 = "2.10.5"
|
||||||
lazy val scala211 = "2.11.7"
|
lazy val scala211 = "2.11.7"
|
||||||
|
|
||||||
val utilVersion = "0.1.0-M3"
|
val utilVersion = "0.1.0-M5"
|
||||||
val ioVersion = "1.0.0-M3"
|
val ioVersion = "1.0.0-M3"
|
||||||
lazy val sbtIO = "org.scala-sbt" %% "io" % ioVersion
|
lazy val sbtIO = "org.scala-sbt" %% "io" % ioVersion
|
||||||
lazy val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion
|
lazy val utilCollection = "org.scala-sbt" %% "util-collection" % utilVersion
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue