From 66e5bad95b6e955c0dbf5285b63520c3b9ab0bda Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Tue, 15 Oct 2024 06:57:39 +0900 Subject: [PATCH] add sbt 2.x cross build setting --- .github/workflows/ci.yml | 2 +- build.sbt | 37 ++++++++++++++++++- .../sbtlicensereport/SbtLicenseReport.scala | 2 +- .../license/LicenseReport.scala | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71c4222..aab3868 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,7 @@ jobs: run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck - shell: bash - run: sbt '++ ${{ matrix.scala }}' test scripted + run: sbt '++ ${{ matrix.scala }}' '+ testAll' - name: Compress target directories shell: bash diff --git a/build.sbt b/build.sbt index 3623a19..9d4de6e 100644 --- a/build.sbt +++ b/build.sbt @@ -2,15 +2,48 @@ lazy val lang3 = "org.apache.commons" % "commons-text" % "1.12.0" lazy val repoSlug = "sbt/sbt-license-report" val scala212 = "2.12.19" +val scala3 = "3.3.3" + +pluginCrossBuild / sbtVersion := { + scalaBinaryVersion.value match { + case "2.12" => + (pluginCrossBuild / sbtVersion).value + case _ => + "2.0.0-M2" + } +} ThisBuild / scalaVersion := scala212 -ThisBuild / crossScalaVersions := Seq(scala212) +ThisBuild / crossScalaVersions := Seq(scala212, scala3) organization := "com.github.sbt" name := "sbt-license-report" enablePlugins(SbtPlugin) libraryDependencies += lang3 scriptedLaunchOpts += s"-Dplugin.version=${version.value}" +ThisBuild / githubWorkflowScalaVersions := Seq(scalaVersion.value) + +TaskKey[Unit]("testAll") := { + if (scalaBinaryVersion.value == "3") { + Def + .sequential( + Test / test, + Def.task( + // TODO enable test + streams.value.log.warn("skip sbt 2.x scripted tests") + ) + ) + .value + } else { + Def + .sequential( + Test / test, + scripted.toTask("") + ) + .value + } +} + // publishing info licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")) scmInfo := Some( @@ -54,7 +87,7 @@ scalacOptions ++= { } else Nil } -ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted"))) +ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("+ testAll"))) ThisBuild / githubWorkflowTargetTags ++= Seq("v*") ThisBuild / githubWorkflowPublishTargetBranches := diff --git a/src/main/scala/sbtlicensereport/SbtLicenseReport.scala b/src/main/scala/sbtlicensereport/SbtLicenseReport.scala index 921af29..6aa9e0e 100644 --- a/src/main/scala/sbtlicensereport/SbtLicenseReport.scala +++ b/src/main/scala/sbtlicensereport/SbtLicenseReport.scala @@ -156,7 +156,7 @@ object SbtLicenseReport extends AutoPlugin { licenseReportNotes := PartialFunction.empty, licenseOverrides := PartialFunction.empty, licenseDepExclusions := PartialFunction.empty, - licenseFilter := TypeFunctions.const(true), + licenseFilter := Function.const(true), licenseReportStyleRules := None, licenseReportTypes := Seq(MarkDown, Html, Csv), licenseReportColumns := Seq(Column.Category, Column.License, Column.Dependency), diff --git a/src/main/scala/sbtlicensereport/license/LicenseReport.scala b/src/main/scala/sbtlicensereport/license/LicenseReport.scala index 2b0a675..5b63ae7 100644 --- a/src/main/scala/sbtlicensereport/license/LicenseReport.scala +++ b/src/main/scala/sbtlicensereport/license/LicenseReport.scala @@ -81,7 +81,7 @@ object LicenseReport { print(language.tableRow(notes, rest: _*)) } print(language.tableEnd) - print(language.documentEnd) + print(language.documentEnd()) } } }