From ce49cf5f92f23484995053108367b22be62dc1ee Mon Sep 17 00:00:00 2001 From: pierscin <30854591+pierscin@users.noreply.github.com> Date: Thu, 24 Sep 2026 10:17:11 +0200 Subject: [PATCH] Migrate to sbt 2.0.9 - Project's sbt is now 2.0.9 - sbt-softwaremill plugins 2.1.0 -> 3.0.1 - Deleted sbt-projectmatrix (built into sbt 2) - Deleted scalajs-env-selenium (unused; browser tests use Playwright since sbt-softwaremill 3.x) - sbt-scalajs 1.19.0 -> 1.22.0, sbt-scala-native 0.5.8 -> 0.5.12, sbt-mima-plugin 1.1.4 -> 1.2.1 - sbt-ide-settings: 1.1.0 -> 1.1.4, org.jetbrains -> org.jetbrains.scala - Scala 2.12.20 -> 2.12.21, 2.13.16 -> 2.13.18, 3.3.6 -> 3.3.8 (Scala.js 1.22 pulls scala-library 2.13.18, and sbt 2 requires the compiler not to be older - SIP-51) - common settings are now bare settings in build.sbt (applied to all subprojects in sbt 2) - sbt 2 syntax adjustments (%%% -> %%, slash syntax, ProjectMatrix no longer in sbt.internal) - put -release 8 explicitly in scalac options for Scala 2 on the JVM - circe-testutils: read resources with scala.io.Source instead of Reader.transferTo (Java 10+) - scala-steward: use the default java version Co-Authored-By: Claude Opus 5.5 --- .github/workflows/scala-steward.yml | 2 - build.sbt | 53 ++++++++----------- .../sttp/apispec/test/ResourcePlatform.scala | 10 ++-- project/build.properties | 2 +- project/plugins.sbt | 13 ++--- 5 files changed, 31 insertions(+), 49 deletions(-) diff --git a/.github/workflows/scala-steward.yml b/.github/workflows/scala-steward.yml index 8ed2e86..6080f92 100644 --- a/.github/workflows/scala-steward.yml +++ b/.github/workflows/scala-steward.yml @@ -15,5 +15,3 @@ jobs: uses: softwaremill/github-actions-workflows/.github/workflows/scala-steward.yml@main secrets: github-token: ${{ secrets.SOFTWAREMILL_CI_PR_TOKEN }} - with: - java-version: '21' diff --git a/build.sbt b/build.sbt index 99a836a..1c04ef2 100644 --- a/build.sbt +++ b/build.sbt @@ -1,11 +1,10 @@ import com.softwaremill.SbtSoftwareMillCommon.commonSmlBuildSettings import com.softwaremill.Publish.ossPublishSettings import sbt.Reference.display -import sbt.internal.ProjectMatrix -val scala2_12 = "2.12.20" -val scala2_13 = "2.13.16" -val scala3 = "3.3.6" +val scala2_12 = "2.12.21" +val scala2_13 = "2.13.18" +val scala3 = "3.3.8" val scalaJVMVersions = List(scala2_12, scala2_13, scala3) val scalaJSVersions = List(scala2_12, scala2_13, scala3) @@ -18,7 +17,7 @@ val circeYamlVersionLatest = "0.16.1" val scalaTestVersion = "3.2.19" val scalaCollectionCompatVersion = "2.11.0" -excludeLintKeys in Global ++= Set(ideSkipProject) +Global / excludeLintKeys ++= Set(ideSkipProject) val scala3Settings = Seq( scalacOptions -= "-Xmax-inlines", @@ -27,13 +26,16 @@ val scala3Settings = Seq( } ) -val commonSettings = commonSmlBuildSettings ++ ossPublishSettings ++ Seq( - organization := "com.softwaremill.sttp.apispec", - mimaPreviousArtifacts := Set.empty, - versionScheme := Some("early-semver") -) ++ scala3Settings +commonSmlBuildSettings +ossPublishSettings +scala3Settings -val commonJvmSettings = commonSettings ++ Seq( +organization := "com.softwaremill.sttp.apispec" +mimaPreviousArtifacts := Set.empty +versionScheme := Some("early-semver") + +val commonJvmSettings = Seq( + scalacOptions ++= (if (ScalaArtifacts.isScala3(scalaVersion.value)) Seq.empty else Seq("-release", "8")), ideSkipProject := (scalaVersion.value != scala2_13), libraryDependencies ++= Seq("org.scalatest" %% "scalatest" % scalaTestVersion % Test), mimaPreviousArtifacts := previousStableVersion.value.map(organization.value %% moduleName.value % _).toSet, @@ -42,7 +44,7 @@ val commonJvmSettings = commonSettings ++ Seq( } ) -val commonJsSettings = commonSettings ++ Seq( +val commonJsSettings = Seq( ideSkipProject := true, Compile / scalacOptions ++= { if (isSnapshot.value) Seq.empty @@ -58,12 +60,12 @@ val commonJsSettings = commonSettings ++ Seq( s"$mapSourcePrefix:$dir->$url/v${version.value}/" } }, - libraryDependencies ++= Seq("org.scalatest" %%% "scalatest" % scalaTestVersion % Test) + libraryDependencies ++= Seq("org.scalatest" %% "scalatest" % scalaTestVersion % Test) ) -val commonNativeSettings = commonSettings ++ Seq( +val commonNativeSettings = Seq( ideSkipProject := true, - libraryDependencies ++= Seq("org.scalatest" %%% "scalatest" % scalaTestVersion % Test) + libraryDependencies ++= Seq("org.scalatest" %% "scalatest" % scalaTestVersion % Test) ) lazy val allProjectAggregates: Seq[ProjectReference] = @@ -89,18 +91,16 @@ lazy val projectAggregates: Seq[ProjectReference] = if (sys.env.isDefinedAt("STT val compileAndTest = "compile->compile;test->test" lazy val rootProject = (project in file(".")) - .settings(commonSettings *) .settings(publish / skip := true, name := "sttp-apispec", scalaVersion := scala2_13) .aggregate(projectAggregates *) lazy val circeTestUtils: ProjectMatrix = (projectMatrix in file("circe-testutils")) - .settings(commonSettings) .settings( publish / skip := true, name := "circe-testutils", libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % circeVersion, - "io.circe" %%% "circe-parser" % circeVersion + "io.circe" %% "circe-core" % circeVersion, + "io.circe" %% "circe-parser" % circeVersion ) ) .jvmPlatform( @@ -118,7 +118,6 @@ lazy val circeTestUtils: ProjectMatrix = (projectMatrix in file("circe-testutils // apispec lazy val apispecModel: ProjectMatrix = (projectMatrix in file("apispec-model")) - .settings(commonSettings) .settings( name := "apispec-model" ) @@ -137,12 +136,11 @@ lazy val apispecModel: ProjectMatrix = (projectMatrix in file("apispec-model")) // jsonschema lazy val jsonSchemaCirce: ProjectMatrix = (projectMatrix in file("jsonschema-circe")) - .settings(commonSettings) .settings( libraryDependencies ++= Seq( - "io.circe" %%% "circe-core" % circeVersion, - "io.circe" %%% "circe-parser" % circeVersion, - "io.circe" %%% "circe-generic" % circeVersion + "io.circe" %% "circe-core" % circeVersion, + "io.circe" %% "circe-parser" % circeVersion, + "io.circe" %% "circe-generic" % circeVersion ), name := "jsonschema-circe" ) @@ -163,7 +161,6 @@ lazy val jsonSchemaCirce: ProjectMatrix = (projectMatrix in file("jsonschema-cir // openapi lazy val openapiModel: ProjectMatrix = (projectMatrix in file("openapi-model")) - .settings(commonSettings) .settings( name := "openapi-model" ) @@ -182,7 +179,6 @@ lazy val openapiModel: ProjectMatrix = (projectMatrix in file("openapi-model")) .dependsOn(apispecModel) lazy val openapiCirce: ProjectMatrix = (projectMatrix in file("openapi-circe")) - .settings(commonSettings) .settings( name := "openapi-circe" ) @@ -201,7 +197,6 @@ lazy val openapiCirce: ProjectMatrix = (projectMatrix in file("openapi-circe")) .dependsOn(openapiModel, jsonSchemaCirce, circeTestUtils % Test) lazy val openapiCirceYaml: ProjectMatrix = (projectMatrix in file("openapi-circe-yaml")) - .settings(commonSettings) .settings( libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, n)) if n <= 12 => @@ -220,7 +215,6 @@ lazy val openapiCirceYaml: ProjectMatrix = (projectMatrix in file("openapi-circe // asyncapi lazy val asyncapiModel: ProjectMatrix = (projectMatrix in file("asyncapi-model")) - .settings(commonSettings) .settings( name := "asyncapi-model" ) @@ -239,7 +233,6 @@ lazy val asyncapiModel: ProjectMatrix = (projectMatrix in file("asyncapi-model") .dependsOn(apispecModel) lazy val asyncapiCirce: ProjectMatrix = (projectMatrix in file("asyncapi-circe")) - .settings(commonSettings) .settings( name := "asyncapi-circe" ) @@ -258,7 +251,6 @@ lazy val asyncapiCirce: ProjectMatrix = (projectMatrix in file("asyncapi-circe") .dependsOn(asyncapiModel, jsonSchemaCirce) lazy val asyncapiCirceYaml: ProjectMatrix = (projectMatrix in file("asyncapi-circe-yaml")) - .settings(commonSettings) .settings( libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, n)) if n <= 12 => @@ -275,7 +267,6 @@ lazy val asyncapiCirceYaml: ProjectMatrix = (projectMatrix in file("asyncapi-cir .dependsOn(asyncapiCirce) lazy val openapiComparatorTests: ProjectMatrix = (projectMatrix in file("openapi-comparator-tests")) - .settings(commonSettings) .settings( name := "openapi-comparator-tests", publish / skip := true diff --git a/circe-testutils/src/main/scalajvm/sttp/apispec/test/ResourcePlatform.scala b/circe-testutils/src/main/scalajvm/sttp/apispec/test/ResourcePlatform.scala index 509e412..d569331 100644 --- a/circe-testutils/src/main/scalajvm/sttp/apispec/test/ResourcePlatform.scala +++ b/circe-testutils/src/main/scalajvm/sttp/apispec/test/ResourcePlatform.scala @@ -2,8 +2,7 @@ package sttp.apispec.test import io.circe._ import io.circe.parser.decode -import java.io.{BufferedReader, InputStreamReader, StringWriter} -import java.nio.charset.StandardCharsets +import scala.io.Source trait ResourcePlatform { @@ -12,11 +11,8 @@ trait ResourcePlatform { */ def basedir: String def readJson(path: String): Either[Error, Json] = { - val is = getClass.getResourceAsStream(path) - val reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)) - val writer = new StringWriter() - reader.transferTo(writer) - decode[Json](writer.toString) + try decode[Json](Source.fromInputStream(is, "UTF-8").mkString) + finally is.close() } } diff --git a/project/build.properties b/project/build.properties index bbb0b60..ddca111 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.11.2 +sbt.version=2.0.9 diff --git a/project/plugins.sbt b/project/plugins.sbt index 35cb5fd..da6ebb2 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,10 @@ -libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1" +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.22.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.12") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.19.0") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.8") -addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.11.0") - -val sbtSoftwareMillVersion = "2.1.0" +val sbtSoftwareMillVersion = "3.0.1" addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion) addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion) addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-browser-test-js" % sbtSoftwareMillVersion) -addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4") +addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.4") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.2.1")