diff --git a/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala b/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala index 91082770..b54058e8 100644 --- a/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala +++ b/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala @@ -125,10 +125,11 @@ private[librarymanagement] abstract class UpdateReportExtra { def stats: UpdateStats private[sbt] def stamps: Map[File, Long] + private[sbt] def moduleKey(m: ModuleID) = (m.organization, m.name, m.revision) + /** All resolved modules in all configurations. */ def allModules: Vector[ModuleID] = { - val key = (m: ModuleID) => (m.organization, m.name, m.revision) - configurations.flatMap(_.allModules).groupBy(key).toVector map { case (_, v) => + configurations.flatMap(_.allModules).groupBy(moduleKey).toVector map { case (_, v) => v reduceLeft { (agg, x) => agg.withConfigurations( (agg.configurations, x.configurations) match { @@ -141,6 +142,21 @@ private[librarymanagement] abstract class UpdateReportExtra { } } + def allModuleReports: Vector[ModuleReport] = { + configurations.flatMap(_.modules).groupBy(mR => moduleKey(mR.module)).toVector map { + case (_, v) => + v reduceLeft { (agg, x) => + agg.withConfigurations( + (agg.configurations, x.configurations) match { + case (v, _) if v.isEmpty => x.configurations + case (ac, v) if v.isEmpty => ac + case (ac, xc) => ac ++ xc + } + ) + } + } + } + def retrieve(f: (ConfigRef, ModuleID, Artifact, File) => File): UpdateReport = UpdateReport(cachedDescriptor, configurations map { _ retrieve f }, stats, stamps) diff --git a/ivy/src/test/scala/sbt/internal/librarymanagement/FakeResolverSpecification.scala b/ivy/src/test/scala/sbt/internal/librarymanagement/FakeResolverSpecification.scala index 89095a51..6ed8f1d7 100644 --- a/ivy/src/test/scala/sbt/internal/librarymanagement/FakeResolverSpecification.scala +++ b/ivy/src/test/scala/sbt/internal/librarymanagement/FakeResolverSpecification.scala @@ -23,6 +23,7 @@ object FakeResolverSpecification extends BaseIvySpecification { val allFiles = getAllFiles(report) assert(report.allModules.length == 1) + assert(report.allModuleReports.length == 1) assert(report.configurations.length == 3) assert(allFiles.toSet.size == 1) assert(allFiles(1).getName == "artifact1-0.0.1-SNAPSHOT.jar") @@ -34,6 +35,7 @@ object FakeResolverSpecification extends BaseIvySpecification { val allFiles = getAllFiles(report).toSet assert(report.allModules.length == 1) + assert(report.allModuleReports.length == 1) assert(report.configurations.length == 3) assert(allFiles.toSet.size == 2) assert(allFiles.map(_.getName) == Set("artifact1-1.0.0.jar", "artifact2-1.0.0.txt")) diff --git a/ivy/src/test/scala/sbt/internal/librarymanagement/FrozenModeSpec.scala b/ivy/src/test/scala/sbt/internal/librarymanagement/FrozenModeSpec.scala index cae7b3f4..ab6a93c9 100644 --- a/ivy/src/test/scala/sbt/internal/librarymanagement/FrozenModeSpec.scala +++ b/ivy/src/test/scala/sbt/internal/librarymanagement/FrozenModeSpec.scala @@ -35,6 +35,7 @@ object FrozenModeSpec extends BaseIvySpecification { val onlineResolution = update(toResolve, onlineConf) assert(onlineResolution.isRight) val numberResolved = onlineResolution.right.get.allModules.size + val numberReportsResolved = onlineResolution.right.get.allModuleReports.size cleanIvyCache() val singleFrozenResolution = update(toResolve, frozenConf) @@ -43,6 +44,10 @@ object FrozenModeSpec extends BaseIvySpecification { singleFrozenResolution.right.get.allModules.size == 1, s"The number of explicit modules in frozen mode should 1" ) + assert( + singleFrozenResolution.right.get.allModuleReports.size == 1, + s"The number of explicit module reports in frozen mode should 1" + ) cleanIvyCache() // This relies on the fact that stoml has 5 transitive dependencies @@ -53,5 +58,9 @@ object FrozenModeSpec extends BaseIvySpecification { frozenResolution.right.get.allModules.size == numberResolved, s"The number of explicit modules in frozen mode should be equal than $numberResolved" ) + assert( + frozenResolution.right.get.allModuleReports.size == numberReportsResolved, + s"The number of explicit module reports in frozen mode should be equal than $numberReportsResolved" + ) } } diff --git a/ivy/src/test/scala/sbt/internal/librarymanagement/InclExclSpec.scala b/ivy/src/test/scala/sbt/internal/librarymanagement/InclExclSpec.scala index d05f115e..7305a2dd 100644 --- a/ivy/src/test/scala/sbt/internal/librarymanagement/InclExclSpec.scala +++ b/ivy/src/test/scala/sbt/internal/librarymanagement/InclExclSpec.scala @@ -68,6 +68,10 @@ object InclExclSpec extends BaseIvySpecification { !report.allModules.exists(_.name.contains("lift-json")), "lift-json has not been excluded." ) + assert( + !report.allModuleReports.exists(_.module.name.contains("lift-json")), + "lift-json has not been excluded." + ) } def testScalaLibraryIsMissing(report: UpdateReport): Unit = { @@ -75,6 +79,10 @@ object InclExclSpec extends BaseIvySpecification { !report.allModules.exists(_.name.contains("scala-library")), "scala-library has not been excluded." ) + assert( + !report.allModuleReports.exists(_.module.name.contains("scala-library")), + "scala-library has not been excluded." + ) } def testScalahostIsMissing(report: UpdateReport): Unit = { @@ -82,5 +90,9 @@ object InclExclSpec extends BaseIvySpecification { !report.allModules.exists(_.name.contains("scalahost")), "scalahost has not been excluded." ) + assert( + !report.allModuleReports.exists(_.module.name.contains("scalahost")), + "scalahost has not been excluded." + ) } }