mirror of https://github.com/sbt/sbt.git
Merge pull request #78 from dwijnand/expose-rich-update-report
Expose RichUpdateReport & DependencyFilter
This commit is contained in:
commit
9b0818f49a
|
|
@ -19,8 +19,7 @@ import org.apache.ivy.plugins.resolver.{ BasicResolver, DependencyResolver }
|
|||
import sbt.io.{ IO, PathFinder }
|
||||
import sbt.util.{ Logger, ShowLines }
|
||||
import sbt.internal.util.{ SourcePosition, LinePosition, RangePosition, LineRange }
|
||||
import sbt.librarymanagement._
|
||||
import sbt.internal.librarymanagement.syntax._
|
||||
import sbt.librarymanagement._, syntax._
|
||||
|
||||
final class DeliverConfiguration(val deliverIvyPattern: String, val status: String, val configurations: Option[Vector[Configuration]], val logging: UpdateLogging)
|
||||
final class PublishConfiguration(val ivyFile: Option[File], val resolverName: String, val artifacts: Map[Artifact, File], val checksums: Vector[String], val logging: UpdateLogging,
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ import report.{ ArtifactDownloadReport, ConfigurationResolveReport, ResolveRepor
|
|||
import resolve.{ IvyNode, IvyNodeCallers }
|
||||
import IvyNodeCallers.{ Caller => IvyCaller }
|
||||
import ivyint.SbtDefaultDependencyDescriptor
|
||||
import sbt.librarymanagement._
|
||||
import sbt.internal.librarymanagement.syntax._
|
||||
import sbt.librarymanagement._, syntax._
|
||||
|
||||
object IvyRetrieve {
|
||||
def reports(report: ResolveReport): Vector[ConfigurationResolveReport] =
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ import annotation.tailrec
|
|||
import scala.concurrent.duration._
|
||||
import sbt.io.{ DirectoryFilter, Hash, IO }
|
||||
import sbt.util.Logger
|
||||
import sbt.librarymanagement._
|
||||
import sbt.internal.librarymanagement.syntax._
|
||||
import sbt.librarymanagement._, syntax._
|
||||
import sbt.internal.util.CacheStore
|
||||
|
||||
private[sbt] object CachedResolutionResolveCache {
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package sbt
|
||||
package internal
|
||||
package librarymanagement
|
||||
|
||||
import sbt.librarymanagement._
|
||||
|
||||
object syntax {
|
||||
implicit def richUpateReport(ur: UpdateReport): RichUpdateReport =
|
||||
new RichUpdateReport(ur)
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt.internal.librarymanagement
|
||||
package sbt.librarymanagement
|
||||
|
||||
import sbt.io.{ AllPassFilter, NameFilter }
|
||||
import sbt.librarymanagement._
|
||||
|
||||
trait DependencyFilterExtra {
|
||||
def moduleFilter(organization: NameFilter = AllPassFilter, name: NameFilter = AllPassFilter, revision: NameFilter = AllPassFilter): ModuleFilter =
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
trait LibraryManagementSyntax {
|
||||
implicit def richUpdateReport(ur: UpdateReport): RichUpdateReport = new RichUpdateReport(ur)
|
||||
}
|
||||
|
||||
object syntax extends LibraryManagementSyntax
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
package sbt
|
||||
package internal
|
||||
package librarymanagement
|
||||
|
||||
import java.io.File
|
||||
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 =
|
||||
private[sbt] def recomputeStamps(): UpdateReport =
|
||||
{
|
||||
val files = report.cachedDescriptor +: allFiles
|
||||
val stamps = files.map(f => (f, f.lastModified)).toMap
|
||||
|
|
@ -17,15 +15,19 @@ final class RichUpdateReport(report: UpdateReport) {
|
|||
import DependencyFilter._
|
||||
|
||||
/** Obtains all successfully retrieved files in all configurations and modules. */
|
||||
def allFiles: Seq[File] = matching(DependencyFilter.allPass)
|
||||
private[sbt] 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
|
||||
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. */
|
||||
def select(configuration: ConfigurationFilter = configurationFilter(), module: ModuleFilter = moduleFilter(), artifact: ArtifactFilter = artifactFilter()): Seq[File] =
|
||||
/** Obtains all successfully retrieved files matching all provided filters. */
|
||||
def select(configuration: ConfigurationFilter, module: ModuleFilter, artifact: ArtifactFilter): Seq[File] =
|
||||
matching(DependencyFilter.make(configuration, module, artifact))
|
||||
|
||||
def select(configuration: ConfigurationFilter): Seq[File] = select(configuration, moduleFilter(), artifactFilter())
|
||||
def select(module: ModuleFilter): Seq[File] = select(configurationFilter(), module, artifactFilter())
|
||||
def select(artifact: ArtifactFilter): Seq[File] = select(configurationFilter(), moduleFilter(), 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)
|
||||
|
|
@ -39,7 +41,8 @@ final class RichUpdateReport(report: UpdateReport) {
|
|||
.withArtifacts(modReport.artifacts filter { case (art, file) => f(configuration, modReport.module, art) })
|
||||
.withMissingArtifacts(modReport.missingArtifacts filter { art => f(configuration, modReport.module, art) })
|
||||
}
|
||||
def substitute(f: (String, ModuleID, Vector[(Artifact, File)]) => Vector[(Artifact, File)]): UpdateReport =
|
||||
|
||||
private[sbt] def substitute(f: (String, ModuleID, Vector[(Artifact, File)]) => Vector[(Artifact, File)]): UpdateReport =
|
||||
moduleReportMap { (configuration, modReport) =>
|
||||
val newArtifacts = f(configuration, modReport.module, modReport.artifacts)
|
||||
modReport
|
||||
|
|
@ -47,19 +50,19 @@ final class RichUpdateReport(report: UpdateReport) {
|
|||
.withMissingArtifacts(modReport.missingArtifacts)
|
||||
}
|
||||
|
||||
def toSeq: Seq[(String, ModuleID, Artifact, File)] =
|
||||
private[sbt] 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)] =
|
||||
private[sbt] 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 =
|
||||
private[sbt] def addMissing(f: ModuleID => Seq[Artifact]): UpdateReport =
|
||||
moduleReportMap { (configuration, modReport) =>
|
||||
modReport
|
||||
.withMissingArtifacts((modReport.missingArtifacts ++ f(modReport.module)).distinct)
|
||||
}
|
||||
|
||||
def moduleReportMap(f: (String, ModuleReport) => ModuleReport): UpdateReport =
|
||||
private[sbt] def moduleReportMap(f: (String, ModuleReport) => ModuleReport): UpdateReport =
|
||||
{
|
||||
val newConfigurations = report.configurations.map { confReport =>
|
||||
import confReport._
|
||||
Loading…
Reference in New Issue