From 92f3095e53381192522b7b51a2b3f85c88924878 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Wed, 3 Jul 2024 01:18:22 +0200 Subject: [PATCH] Use 'update' instead of ivy resolution Reproduces #87 --- project/build.properties | 2 +- .../sbtlicensereport/SbtLicenseReport.scala | 4 +-- .../license/LicenseReport.scala | 29 ++----------------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/project/build.properties b/project/build.properties index 04267b1..081fdbb 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.9 +sbt.version=1.10.0 diff --git a/src/main/scala/sbtlicensereport/SbtLicenseReport.scala b/src/main/scala/sbtlicensereport/SbtLicenseReport.scala index 921af29..bead016 100644 --- a/src/main/scala/sbtlicensereport/SbtLicenseReport.scala +++ b/src/main/scala/sbtlicensereport/SbtLicenseReport.scala @@ -82,13 +82,11 @@ object SbtLicenseReport extends AutoPlugin { Seq( licenseReportTitle := s"${normalizedName.value}-licenses", updateLicenses := { - val ignore = update.value val overrides = licenseOverrides.value.lift val depExclusions = licenseDepExclusions.value.lift val originatingModule = DepModuleInfo(organization.value, name.value, version.value) license.LicenseReport.makeReport( - ivyModule.value, - IvyDependencyResolution(ivyConfiguration.value), + updateFull.value, licenseConfigurations.value, licenseSelection.value, overrides, diff --git a/src/main/scala/sbtlicensereport/license/LicenseReport.scala b/src/main/scala/sbtlicensereport/license/LicenseReport.scala index afc691a..deb73c2 100644 --- a/src/main/scala/sbtlicensereport/license/LicenseReport.scala +++ b/src/main/scala/sbtlicensereport/license/LicenseReport.scala @@ -117,8 +117,7 @@ object LicenseReport { } def makeReport( - module: IvySbt#Module, - depRes: DependencyResolution, + updateReport: UpdateReport, configs: Set[String], licenseSelection: Seq[LicenseCategory], overrides: DepModuleInfo => Option[LicenseInfo], @@ -126,14 +125,6 @@ object LicenseReport { originatingModule: DepModuleInfo, log: Logger ): LicenseReport = { - // Ideally we should be using just standard sbt update task however due to - // https://github.com/coursier/coursier/issues/1790 coursier cannot correctly - // resolve license information from Ivy modules, so instead we just use - // IvyDependencyResolution directly - val updateReport = resolve(depRes, module, log) match { - case Left(exception) => throw exception.resolveException - case Right(updateReport) => updateReport - } makeReportImpl(updateReport, configs, licenseSelection, overrides, exclusions, originatingModule, log) } @@ -190,22 +181,6 @@ 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, @@ -213,7 +188,7 @@ object LicenseReport { originatingModule: DepModuleInfo ): Seq[DepLicense] = { for { - dep <- allModuleReports(report.configurations) + dep <- report.allModuleReports report <- pickLicenseForDep(dep, configs, categories, originatingModule) } yield report }