From 764e43cf66df2c22584130f24fd341dca26a025d Mon Sep 17 00:00:00 2001 From: pierscin <30854591+pierscin@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:08:28 +0200 Subject: [PATCH 1/2] Migrate to sbt 2.0.9 and sbt-softwaremill 3.0.1 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 2 +- .scalafmt.conf | 5 +- build.sbt | 47 ++++++++++--------- project/build.properties | 2 +- project/plugins.sbt | 4 +- .../com/softwaremill/macwire/Properties.scala | 2 +- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fbe3931..11749dbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: github.event.pull_request.user.login == 'softwaremill-ci' strategy: matrix: - java: [ '11', '17', '21' ] + java: [ '17', '21' ] fail-fast: false with: java-version: ${{ matrix.java }} diff --git a/.scalafmt.conf b/.scalafmt.conf index 4dffb6f5..0d989cc2 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -5,4 +5,7 @@ fileOverride { "glob:**/scala-3/**" { runner.dialect = scala3 } -} \ No newline at end of file + "glob:**.sbt" { + runner.dialect = scala3 + } +} diff --git a/build.sbt b/build.sbt index abcb38c0..0716702f 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ import com.softwaremill.UpdateVersionInDocs import sbt._ import sbt.Keys._ -excludeLintKeys in Global ++= Set(ideSkipProject) +Global / excludeLintKeys ++= Set(ideSkipProject) val scala2_12 = "2.12.21" val scala2_13 = "2.13.18" @@ -49,33 +49,42 @@ val versionSpecificScalaSources = { } } -val commonSettings = commonSmlBuildSettings ++ ossPublishSettings ++ Seq( - organization := "com.softwaremill.macwire", - ideSkipProject := (scalaVersion.value != ideScalaVersion) || thisProjectRef.value.project.contains("JS"), - bspEnabled := !ideSkipProject.value, - scalacOptions ~= (_.filterNot(Set("-Wconf:cat=other-match-analysis:error"))) // doesn't play well with macros -) +commonSmlBuildSettings +ossPublishSettings + +organization := "com.softwaremill.macwire" +ideSkipProject := (scalaVersion.value != ideScalaVersion) || thisProjectRef.value.project.contains("JS") +bspEnabled := !ideSkipProject.value +scalacOptions ~= (_.filterNot(Set("-Wconf:cat=other-match-analysis:error"))) // doesn't play well with macros -val testSettings = commonSettings ++ Seq( +val testSettings = Seq( publishArtifact := false, scalacOptions ++= Seq("-Ywarn-dead-code"), // Otherwise when running tests in sbt, the macro is not visible // (both macro and usages are compiled in the same compiler run) - Test / fork := true + Test / fork := true, + // compile tests list the test-case resources as files, which doesn't work with jars on the classpath (the sbt 2 default) + exportJars := false, + // in sbt 2 forked tests are run by a worker, so java.class.path doesn't contain the test classpath needed by the Scala 3 compile tests + Test / javaOptions += { + val converter = fileConverter.value + val classpath = (Test / fullClasspath).value.map(a => converter.toPath(a.data).toString) + s"-Dmacwire.test.classpath=${classpath.mkString(java.io.File.pathSeparator)}" + } ) -val tagging = "com.softwaremill.common" %% "tagging" % "2.3.5" +// `%%` is platform-aware in sbt 2; the JVM artifacts are pinned to keep the dependencies of the published JS/Native modules unchanged +val tagging = ("com.softwaremill.common" %% "tagging" % "2.3.5").platform(Platform.jvm) val scalatest = "org.scalatest" %% "scalatest" % "3.2.20" val javassist = "org.javassist" % "javassist" % "3.33.0-GA" -val akkaActor = "com.typesafe.akka" %% "akka-actor" % "2.6.21" -val pekkoActor = "org.apache.pekko" %% "pekko-actor" % "1.7.0" +val akkaActor = ("com.typesafe.akka" %% "akka-actor" % "2.6.21").platform(Platform.jvm) +val pekkoActor = ("org.apache.pekko" %% "pekko-actor" % "1.7.0").platform(Platform.jvm) val javaxInject = "javax.inject" % "javax.inject" % "1" -val cats = "org.typelevel" %% "cats-core" % "2.13.0" -val catsEffect = "org.typelevel" %% "cats-effect" % "3.7.1" +val cats = ("org.typelevel" %% "cats-core" % "2.13.0").platform(Platform.jvm) +val catsEffect = ("org.typelevel" %% "cats-effect" % "3.7.1").platform(Platform.jvm) lazy val root = project .in(file(".")) - .settings(commonSettings) .settings(name := "macwire", publishArtifact := false) .aggregate( List( @@ -92,20 +101,18 @@ lazy val root = project macrosPekkoTests, macrosAutoCats, macrosAutoCatsTests - ).flatMap(_.projectRefs): _* + ).flatMap(_.projectRefs)* ) lazy val util = projectMatrix .in(file("util")) .settings(libraryDependencies += tagging) - .settings(commonSettings) .jvmPlatform(scalaVersions = scala2And3Versions) .jsPlatform(scalaVersions = scala2And3Versions) .nativePlatform(scalaVersions = scala2And3Versions) lazy val macros = projectMatrix .in(file("macros")) - .settings(commonSettings) .settings( libraryDependencies ++= reflectLibrary(scalaVersion.value), versionSpecificScalaSources @@ -117,7 +124,6 @@ lazy val macros = projectMatrix lazy val proxy = projectMatrix .in(file("proxy")) - .settings(commonSettings) .settings( libraryDependencies ++= Seq(javassist, scalatest % Test), compileOrder := CompileOrder.JavaThenScala, @@ -162,7 +168,6 @@ lazy val tests2 = projectMatrix lazy val macrosAkka = projectMatrix .in(file("macrosAkka")) - .settings(commonSettings) .settings(libraryDependencies ++= Seq(akkaActor % "provided")) .dependsOn(macros) .jvmPlatform(scalaVersions = scala2) @@ -170,7 +175,6 @@ lazy val macrosAkka = projectMatrix lazy val macrosPekko = projectMatrix .in(file("macrosPekko")) - .settings(commonSettings) .settings(libraryDependencies ++= Seq(pekkoActor % "provided")) .dependsOn(macros) .jvmPlatform(scalaVersions = scala2) @@ -204,7 +208,6 @@ lazy val macrosPekkoTests = projectMatrix lazy val macrosAutoCats = projectMatrix .in(file("macrosAutoCats")) - .settings(commonSettings) .settings(libraryDependencies ++= Seq(catsEffect, cats)) .dependsOn(macros) .jvmPlatform(scalaVersions = scala2) diff --git a/project/build.properties b/project/build.properties index e0a1aa02..ddca111e 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.13.0 +sbt.version=2.0.9 diff --git a/project/plugins.sbt b/project/plugins.sbt index f5229c8a..4f0ae563 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,4 @@ -addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.11.0") - -val sbtSoftwareMillVersion = "2.1.2" +val sbtSoftwareMillVersion = "3.0.1" addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion) addSbtPlugin("com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion) diff --git a/test-util/src/main/scala-3/com/softwaremill/macwire/Properties.scala b/test-util/src/main/scala-3/com/softwaremill/macwire/Properties.scala index e1bf3d55..5dd10871 100644 --- a/test-util/src/main/scala-3/com/softwaremill/macwire/Properties.scala +++ b/test-util/src/main/scala-3/com/softwaremill/macwire/Properties.scala @@ -3,5 +3,5 @@ package com.softwaremill.macwire import java.io.File object Properties { - def currentClasspath = sys.props("java.class.path") + def currentClasspath = sys.props.getOrElse("macwire.test.classpath", sys.props("java.class.path")) } From 8488f6d384e53bf0e43ae2a4e13c2a51d0c03e42 Mon Sep 17 00:00:00 2001 From: pierscin <30854591+pierscin@users.noreply.github.com> Date: Thu, 1 Oct 2026 14:27:55 +0200 Subject: [PATCH 2/2] use rootProject and autoAggregate --- build.sbt | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/build.sbt b/build.sbt index 0716702f..846b5e94 100644 --- a/build.sbt +++ b/build.sbt @@ -63,7 +63,6 @@ val testSettings = Seq( // Otherwise when running tests in sbt, the macro is not visible // (both macro and usages are compiled in the same compiler run) Test / fork := true, - // compile tests list the test-case resources as files, which doesn't work with jars on the classpath (the sbt 2 default) exportJars := false, // in sbt 2 forked tests are run by a worker, so java.class.path doesn't contain the test classpath needed by the Scala 3 compile tests Test / javaOptions += { @@ -73,7 +72,6 @@ val testSettings = Seq( } ) -// `%%` is platform-aware in sbt 2; the JVM artifacts are pinned to keep the dependencies of the published JS/Native modules unchanged val tagging = ("com.softwaremill.common" %% "tagging" % "2.3.5").platform(Platform.jvm) val scalatest = "org.scalatest" %% "scalatest" % "3.2.20" val javassist = "org.javassist" % "javassist" % "3.33.0-GA" @@ -83,26 +81,9 @@ val javaxInject = "javax.inject" % "javax.inject" % "1" val cats = ("org.typelevel" %% "cats-core" % "2.13.0").platform(Platform.jvm) val catsEffect = ("org.typelevel" %% "cats-effect" % "3.7.1").platform(Platform.jvm) -lazy val root = project - .in(file(".")) +lazy val root = rootProject .settings(name := "macwire", publishArtifact := false) - .aggregate( - List( - util, - macros, - proxy, - tests, - tests2, - testUtil, - utilTests, - macrosAkka, - macrosPekko, - macrosAkkaTests, - macrosPekkoTests, - macrosAutoCats, - macrosAutoCatsTests - ).flatMap(_.projectRefs)* - ) + .autoAggregate lazy val util = projectMatrix .in(file("util"))