Skip to content

Commit

Permalink
Use allModuleReports from sbt 1.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Sep 14, 2023
1 parent 5bdab60 commit 2faa77c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ name := "sbt-license-report"
enablePlugins(SbtPlugin)
libraryDependencies += lang3
scriptedLaunchOpts += s"-Dplugin.version=${version.value}"
pluginCrossBuild / sbtVersion := "1.9.5"

// publishing info
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html"))
Expand Down
18 changes: 1 addition & 17 deletions src/main/scala/sbtlicensereport/license/LicenseReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -190,30 +190,14 @@ object LicenseReport {
}
}

// TODO: Use https://github.com/sbt/librarymanagement/pull/428 instead when merged and released
private def moduleKey(m: ModuleID) = (m.organization, m.name, m.revision)

private def allModuleReports(configurations: Vector[ConfigurationReport]): 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
}
)
}
}

private def getLicenses(
report: UpdateReport,
configs: Set[String] = Set.empty,
categories: Seq[LicenseCategory] = LicenseCategory.all,
originatingModule: DepModuleInfo
): Seq[DepLicense] = {
for {
dep <- allModuleReports(report.configurations)
dep <- report.allModuleReports
report <- pickLicenseForDep(dep, configs, categories, originatingModule)
} yield report
}
Expand Down

0 comments on commit 2faa77c

Please sign in to comment.