-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose more in RichUpdateReport #84
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,10 @@ package librarymanagement | |
|
||
import java.io.File | ||
|
||
/** Provides extra methods for filtering the contents of an `UpdateReport` and for obtaining references to a selected subset of the underlying files. */ | ||
/** | ||
* 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) { | ||
private[sbt] def recomputeStamps(): UpdateReport = | ||
{ | ||
|
@@ -15,10 +18,10 @@ final class RichUpdateReport(report: UpdateReport) { | |
import DependencyFilter._ | ||
|
||
/** Obtains all successfully retrieved files in all configurations and modules. */ | ||
private[sbt] def allFiles: Seq[File] = matching(DependencyFilter.allPass) | ||
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 | ||
def matching(f: DependencyFilter): Seq[File] = select0(f).distinct | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same return Vector. |
||
|
||
/** Obtains all successfully retrieved files matching all provided filters. */ | ||
def select(configuration: ConfigurationFilter, module: ModuleFilter, artifact: ArtifactFilter): Seq[File] = | ||
|
@@ -29,17 +32,27 @@ final class RichUpdateReport(report: UpdateReport) { | |
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) | ||
for { | ||
cReport <- report.configurations | ||
mReport <- cReport.modules | ||
(artifact, file) <- mReport.artifacts | ||
if f(cReport.configuration, mReport.module, artifact) | ||
} yield { | ||
if (file == null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should either use |
||
sys.error(s"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 = | ||
def filter(f: DependencyFilter): UpdateReport = | ||
moduleReportMap { (configuration, modReport) => | ||
modReport | ||
.withArtifacts(modReport.artifacts filter { case (art, file) => f(configuration, modReport.module, art) }) | ||
.withMissingArtifacts(modReport.missingArtifacts filter { art => f(configuration, modReport.module, art) }) | ||
.withArtifacts( | ||
modReport.artifacts filter { case (art, file) => f(configuration, modReport.module, art) } | ||
) | ||
.withMissingArtifacts( | ||
modReport.missingArtifacts filter { art => f(configuration, modReport.module, art) } | ||
) | ||
} | ||
|
||
private[sbt] def substitute(f: (String, ModuleID, Vector[(Artifact, File)]) => Vector[(Artifact, File)]): UpdateReport = | ||
|
@@ -50,11 +63,19 @@ final class RichUpdateReport(report: UpdateReport) { | |
.withMissingArtifacts(modReport.missingArtifacts) | ||
} | ||
|
||
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 toSeq: Seq[(String, ModuleID, Artifact, File)] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
for { | ||
confReport <- report.configurations | ||
modReport <- confReport.modules | ||
(artifact, file) <- modReport.artifacts | ||
} yield (confReport.configuration, modReport.module, artifact, file) | ||
|
||
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 allMissing: Seq[(String, ModuleID, Artifact)] = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
for { | ||
confReport <- report.configurations | ||
modReport <- confReport.modules | ||
artifact <- modReport.missingArtifacts | ||
} yield (confReport.configuration, modReport.module, artifact) | ||
|
||
private[sbt] def addMissing(f: ModuleID => Seq[Artifact]): UpdateReport = | ||
moduleReportMap { (configuration, modReport) => | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use Vectors.