Skip to content

Commit

Permalink
Use Configuration type in licenseConfigurations
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed May 13, 2023
1 parent 5adfc8c commit 0be9f86
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/sbtlicensereport/SbtLicenseReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object SbtLicenseReport extends AutoPlugin {
val licenseReportDir = settingKey[File]("The location where we'll write the license reports.")
val licenseReportStyleRules = settingKey[Option[String]]("The style rules for license report styling.")
val licenseReportTitle = settingKey[String]("The name of the license report.")
val licenseConfigurations = settingKey[Set[String]]("The ivy configurations we wish a report of.")
val licenseConfigurations = settingKey[Set[Configuration]]("The ivy configurations we wish a report of.")
val licenseSelection = settingKey[Seq[LicenseCategory]](
"A priority-order list mechanism we can use to select licenses for builds that have more than one."
)
Expand Down Expand Up @@ -137,7 +137,7 @@ object SbtLicenseReport extends AutoPlugin {

override lazy val globalSettings = Seq(
licenseSelection := LicenseCategory.all,
licenseConfigurations := Set("compile", "test"),
licenseConfigurations := Set(Compile, Test),
// Here we use an empty partial function
licenseReportNotes := PartialFunction.empty,
licenseOverrides := PartialFunction.empty,
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/sbtlicensereport/license/LicenseReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ object LicenseReport {

def makeReport(
module: IvySbt#Module,
configs: Set[String],
configs: Set[Configuration],
licenseSelection: Seq[LicenseCategory],
overrides: DepModuleInfo => Option[LicenseInfo],
exclusions: DepModuleInfo => Option[Boolean],
Expand Down Expand Up @@ -123,14 +123,14 @@ object LicenseReport {
/** Picks a single license (or none) for this dependency. */
private def pickLicenseForDep(
dep: IvyNode,
configs: Set[String],
configs: Set[Configuration],
categories: Seq[LicenseCategory],
originatingModule: DepModuleInfo
): Option[DepLicense] =
for {
d <- Option(dep)
cs = dep.getRootModuleConfigurations.toSet
filteredConfigs = if (cs.isEmpty) cs else cs.filter(configs)
filteredConfigs = if (cs.isEmpty) cs else cs.filter(configs.map(_.name))
if !filteredConfigs.isEmpty
if !filteredConfigs.forall(d.isEvicted)
desc <- Option(dep.getDescriptor)
Expand All @@ -155,7 +155,7 @@ object LicenseReport {

private def getLicenses(
report: ResolveReport,
configs: Set[String] = Set.empty,
configs: Set[Configuration] = Set.empty,
categories: Seq[LicenseCategory] = LicenseCategory.all,
originatingModule: DepModuleInfo
): Seq[DepLicense] = {
Expand All @@ -168,7 +168,7 @@ object LicenseReport {

private def makeReportImpl(
report: ResolveReport,
configs: Set[String],
configs: Set[Configuration],
categories: Seq[LicenseCategory],
overrides: DepModuleInfo => Option[LicenseInfo],
exclusions: DepModuleInfo => Option[Boolean],
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/dumpLicenseReport/custom-report/example.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "example"

licenseReportTitle := "lreport"

licenseConfigurations := Set("compile")
licenseConfigurations := Set(Compile)

licenseSelection := Seq(LicenseCategory.BSD)

Expand Down

0 comments on commit 0be9f86

Please sign in to comment.