From 3a7b8effe32c199130eaadc6bc99401d37ea9ce6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 6 Nov 2023 09:48:49 +0800 Subject: [PATCH] Update to Mill 0.11.x (#310) * Went to a newer version of Scala 3 to let us remove some workarounds in docjar publishing * Dropped Scala 2.11 support since the version of Scala-Native that supports Scala-3 doesn't support Scala 2.11 * Updated `build.sc` syntax (e.g. cross modules are now `trait`s) and made use of new `PlatformScalaModule` helper trait to substitute custom `def sources` mangling * Moved source files to standard `PlatformScalaModule` directory layout, i.e. a flat list of `src--/` folders for every scala version and scala platform * Drop cross-building for Scala.js/Scala-Native version since they only supported one version anyway --- .github/workflows/actions.yml | 2 +- .mill-version | 2 +- build.sc | 99 ++++--------------- mill | 2 +- .../utest/PlatformShims.scala | 0 .../utest/EnableReflectiveInstantiation.java | 0 .../utest/PlatformShims.scala | 0 .../utest/PortableScalaReflectExcerpts.scala | 0 .../src => src-js}/utest/PlatformShims.scala | 0 .../src => src-jvm}/utest/PlatformShims.scala | 0 .../utest/PlatformShims.scala | 0 .../src-2-js}/test/utest/TestUtil.scala | 0 .../src-2-native}/test/utest/TestUtil.scala | 0 .../test/utest/FormatterTests.scala | 0 .../src-3-js}/test/utest/TestUtil.scala | 0 .../src-3-native}/test/utest/TestUtil.scala | 0 .../test/utest/DefaultParamsTests.scala | 0 .../src-js}/test/utest/Scheduler.scala | 0 .../src-jvm}/test/utest/Parallel.scala | 0 .../src-jvm}/test/utest/Scheduler.scala | 0 .../src-jvm}/test/utest/TestUtil.scala | 0 .../src-native}/test/utest/Scheduler.scala | 0 22 files changed, 23 insertions(+), 82 deletions(-) rename utest/{jvm/src-2 => src-2-jvm}/utest/PlatformShims.scala (100%) rename utest/{jvm/src-3 => src-3-jvm}/utest/EnableReflectiveInstantiation.java (100%) rename utest/{jvm/src-3 => src-3-jvm}/utest/PlatformShims.scala (100%) rename utest/{jvm/src-3 => src-3-jvm}/utest/PortableScalaReflectExcerpts.scala (100%) rename utest/{js/src => src-js}/utest/PlatformShims.scala (100%) rename utest/{jvm/src => src-jvm}/utest/PlatformShims.scala (100%) rename utest/{native/src => src-native}/utest/PlatformShims.scala (100%) rename utest/{js/test/src-2 => test/src-2-js}/test/utest/TestUtil.scala (100%) rename utest/{native/test/src-2 => test/src-2-native}/test/utest/TestUtil.scala (100%) rename utest/{jvm/test/src-2.12 => test/src-2.12-jvm}/test/utest/FormatterTests.scala (100%) rename utest/{js/test/src-3 => test/src-3-js}/test/utest/TestUtil.scala (100%) rename utest/{native/test/src-3 => test/src-3-native}/test/utest/TestUtil.scala (100%) rename utest/{js/test/src => test/src-js}/test/utest/DefaultParamsTests.scala (100%) rename utest/{js/test/src => test/src-js}/test/utest/Scheduler.scala (100%) rename utest/{jvm/test/src => test/src-jvm}/test/utest/Parallel.scala (100%) rename utest/{jvm/test/src => test/src-jvm}/test/utest/Scheduler.scala (100%) rename utest/{jvm/test/src => test/src-jvm}/test/utest/TestUtil.scala (100%) rename utest/{native/test/src => test/src-native}/test/utest/Scheduler.scala (100%) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index fe96529d..9c30d20a 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -24,7 +24,7 @@ jobs: java-version: ${{ matrix.java }} - name: Run tests - run: ./mill -i all __.publishArtifacts __.test + run: ./mill -i '__.{publishArtifacts,test}' check-binary-compatibility: runs-on: ubuntu-latest diff --git a/.mill-version b/.mill-version index 51114462..b799a8ca 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.10.12 \ No newline at end of file +0.11.5 \ No newline at end of file diff --git a/build.sc b/build.sc index 46309a8e..56997b7e 100644 --- a/build.sc +++ b/build.sc @@ -1,16 +1,12 @@ import mill._, scalalib._, scalajslib._, scalanativelib._, publish._ -import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.3.1` +import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0` import de.tobiasroeser.mill.vcs.version.VcsVersion -import $ivy.`com.github.lolgab::mill-mima::0.0.19` +import $ivy.`com.github.lolgab::mill-mima::0.0.24` import com.github.lolgab.mill.mima._ -import mill.scalalib.api.Util.isScala3 val communityBuildDottyVersion = sys.props.get("dottyVersion").toList -val scalaVersions = "2.11.12" :: "2.12.17" :: "2.13.10" :: "3.1.3" :: communityBuildDottyVersion - -val scalaJSVersions = scalaVersions.map((_, "1.12.0")) -val scalaNativeVersions = scalaVersions.map((_, "0.4.9")) +val scalaVersions = "2.12.17" :: "2.13.10" :: "3.3.1" :: communityBuildDottyVersion val scalaReflectVersion = "1.1.2" @@ -18,16 +14,9 @@ trait MimaCheck extends Mima { def mimaPreviousVersions = VcsVersion.vcsState().lastTag.toSeq } -trait UtestModule extends PublishModule with MimaCheck { +trait UtestModule extends PublishModule with MimaCheck with PlatformScalaModule{ def artifactName = "utest" - def crossScalaVersion: String - - // Temporary until the next version of Mima gets released with - // https://github.com/lightbend/mima/issues/693 included in the release. - def mimaPreviousArtifacts = - if(isScala3(crossScalaVersion)) Agg.empty[Dep] else super.mimaPreviousArtifacts() - def publishVersion = VcsVersion.vcsState().format() def pomSettings = PomSettings( @@ -41,93 +30,45 @@ trait UtestModule extends PublishModule with MimaCheck { ) ) } -abstract class UtestMainModule(crossScalaVersion: String) extends CrossScalaModule { - def millSourcePath = super.millSourcePath / offset - - def offset: os.RelPath = os.rel - def sources = T.sources( - super.sources() - .flatMap(source => - Seq( - PathRef(source.path / os.up / source.path.last), - PathRef(source.path / os.up / os.up / source.path.last), - ) - ) - ) - override def docJar = - if (crossScalaVersion.startsWith("2")) super.docJar - else T { - val outDir = T.ctx().dest - val javadocDir = outDir / 'javadoc - os.makeDir.all(javadocDir) - mill.api.Result.Success(mill.modules.Jvm.createJar(Agg(javadocDir))(outDir)) - } -} +trait UtestMainModule extends CrossScalaModule with UtestModule -trait UtestTestModule extends ScalaModule with TestModule { - def crossScalaVersion: String +trait UtestTestModule extends TestModule { def testFramework = "test.utest.CustomFramework" - def offset: os.RelPath = os.rel - def millSourcePath = super.millSourcePath / os.up - - def sources = T.sources( - super.sources() - .++(CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" )) - .flatMap(source => - Seq( - PathRef(source.path / os.up / "test" / source.path.last), - PathRef(source.path / os.up / os.up / "test" / source.path.last), - ) - ) - .distinct - ) } object utest extends Module { - object jvm extends Cross[JvmUtestModule](scalaVersions: _*) - class JvmUtestModule(val crossScalaVersion: String) - extends UtestMainModule(crossScalaVersion) with ScalaModule with UtestModule { + object jvm extends Cross[JvmUtestModule](scalaVersions) + trait JvmUtestModule + extends UtestMainModule { def ivyDeps = Agg( ivy"org.scala-sbt:test-interface::1.0" ) ++ (if (crossScalaVersion.startsWith("2")) Agg( ivy"org.portable-scala::portable-scala-reflect::$scalaReflectVersion", ivy"org.scala-lang:scala-reflect:$crossScalaVersion" ) else Agg()) - object test extends Tests with UtestTestModule{ - val crossScalaVersion = JvmUtestModule.this.crossScalaVersion - } + object test extends ScalaTests with UtestTestModule } - object js extends Cross[JsUtestModule](scalaJSVersions: _*) - class JsUtestModule(val crossScalaVersion: String, crossJSVersion: String) - extends UtestMainModule(crossScalaVersion) with ScalaJSModule with UtestModule { - def offset = os.up + object js extends Cross[JsUtestModule](scalaVersions) + trait JsUtestModule extends UtestMainModule with ScalaJSModule{ def ivyDeps = Agg( - ivy"org.scala-js::scalajs-test-interface:$crossJSVersion".withDottyCompat(crossScalaVersion), + ivy"org.scala-js::scalajs-test-interface:${scalaJSVersion()}".withDottyCompat(crossScalaVersion), ivy"org.portable-scala::portable-scala-reflect::$scalaReflectVersion".withDottyCompat(crossScalaVersion) ) ++ (if(crossScalaVersion.startsWith("2")) Agg( ivy"org.scala-lang:scala-reflect:$crossScalaVersion" ) else Agg()) - def scalaJSVersion = crossJSVersion - object test extends Tests with UtestTestModule{ - def offset = os.up - val crossScalaVersion = JsUtestModule.this.crossScalaVersion - } + def scalaJSVersion = "1.12.0" + object test extends ScalaJSTests with UtestTestModule } - object native extends Cross[NativeUtestModule](scalaNativeVersions: _*) - class NativeUtestModule(val crossScalaVersion: String, crossScalaNativeVersion: String) - extends UtestMainModule(crossScalaVersion) with ScalaNativeModule with UtestModule { - def offset = os.up + object native extends Cross[NativeUtestModule](scalaVersions) + trait NativeUtestModule extends UtestMainModule with ScalaNativeModule { def ivyDeps = super.ivyDeps() ++ Agg( - ivy"org.scala-native::test-interface::$crossScalaNativeVersion" + ivy"org.scala-native::test-interface::${scalaNativeVersion()}" ) - def scalaNativeVersion = crossScalaNativeVersion - object test extends Tests with UtestTestModule{ - def offset = os.up - val crossScalaVersion = NativeUtestModule.this.crossScalaVersion - } + def scalaNativeVersion = "0.4.16" + object test extends ScalaNativeTests with UtestTestModule } } diff --git a/mill b/mill index e616548f..0ddd69f8 100755 --- a/mill +++ b/mill @@ -3,7 +3,7 @@ # This is a wrapper script, that automatically download mill from GitHub release pages # You can give the required mill version with MILL_VERSION env variable # If no version is given, it falls back to the value of DEFAULT_MILL_VERSION -DEFAULT_MILL_VERSION=0.10.5 +DEFAULT_MILL_VERSION=0.11.5 set -e diff --git a/utest/jvm/src-2/utest/PlatformShims.scala b/utest/src-2-jvm/utest/PlatformShims.scala similarity index 100% rename from utest/jvm/src-2/utest/PlatformShims.scala rename to utest/src-2-jvm/utest/PlatformShims.scala diff --git a/utest/jvm/src-3/utest/EnableReflectiveInstantiation.java b/utest/src-3-jvm/utest/EnableReflectiveInstantiation.java similarity index 100% rename from utest/jvm/src-3/utest/EnableReflectiveInstantiation.java rename to utest/src-3-jvm/utest/EnableReflectiveInstantiation.java diff --git a/utest/jvm/src-3/utest/PlatformShims.scala b/utest/src-3-jvm/utest/PlatformShims.scala similarity index 100% rename from utest/jvm/src-3/utest/PlatformShims.scala rename to utest/src-3-jvm/utest/PlatformShims.scala diff --git a/utest/jvm/src-3/utest/PortableScalaReflectExcerpts.scala b/utest/src-3-jvm/utest/PortableScalaReflectExcerpts.scala similarity index 100% rename from utest/jvm/src-3/utest/PortableScalaReflectExcerpts.scala rename to utest/src-3-jvm/utest/PortableScalaReflectExcerpts.scala diff --git a/utest/js/src/utest/PlatformShims.scala b/utest/src-js/utest/PlatformShims.scala similarity index 100% rename from utest/js/src/utest/PlatformShims.scala rename to utest/src-js/utest/PlatformShims.scala diff --git a/utest/jvm/src/utest/PlatformShims.scala b/utest/src-jvm/utest/PlatformShims.scala similarity index 100% rename from utest/jvm/src/utest/PlatformShims.scala rename to utest/src-jvm/utest/PlatformShims.scala diff --git a/utest/native/src/utest/PlatformShims.scala b/utest/src-native/utest/PlatformShims.scala similarity index 100% rename from utest/native/src/utest/PlatformShims.scala rename to utest/src-native/utest/PlatformShims.scala diff --git a/utest/js/test/src-2/test/utest/TestUtil.scala b/utest/test/src-2-js/test/utest/TestUtil.scala similarity index 100% rename from utest/js/test/src-2/test/utest/TestUtil.scala rename to utest/test/src-2-js/test/utest/TestUtil.scala diff --git a/utest/native/test/src-2/test/utest/TestUtil.scala b/utest/test/src-2-native/test/utest/TestUtil.scala similarity index 100% rename from utest/native/test/src-2/test/utest/TestUtil.scala rename to utest/test/src-2-native/test/utest/TestUtil.scala diff --git a/utest/jvm/test/src-2.12/test/utest/FormatterTests.scala b/utest/test/src-2.12-jvm/test/utest/FormatterTests.scala similarity index 100% rename from utest/jvm/test/src-2.12/test/utest/FormatterTests.scala rename to utest/test/src-2.12-jvm/test/utest/FormatterTests.scala diff --git a/utest/js/test/src-3/test/utest/TestUtil.scala b/utest/test/src-3-js/test/utest/TestUtil.scala similarity index 100% rename from utest/js/test/src-3/test/utest/TestUtil.scala rename to utest/test/src-3-js/test/utest/TestUtil.scala diff --git a/utest/native/test/src-3/test/utest/TestUtil.scala b/utest/test/src-3-native/test/utest/TestUtil.scala similarity index 100% rename from utest/native/test/src-3/test/utest/TestUtil.scala rename to utest/test/src-3-native/test/utest/TestUtil.scala diff --git a/utest/js/test/src/test/utest/DefaultParamsTests.scala b/utest/test/src-js/test/utest/DefaultParamsTests.scala similarity index 100% rename from utest/js/test/src/test/utest/DefaultParamsTests.scala rename to utest/test/src-js/test/utest/DefaultParamsTests.scala diff --git a/utest/js/test/src/test/utest/Scheduler.scala b/utest/test/src-js/test/utest/Scheduler.scala similarity index 100% rename from utest/js/test/src/test/utest/Scheduler.scala rename to utest/test/src-js/test/utest/Scheduler.scala diff --git a/utest/jvm/test/src/test/utest/Parallel.scala b/utest/test/src-jvm/test/utest/Parallel.scala similarity index 100% rename from utest/jvm/test/src/test/utest/Parallel.scala rename to utest/test/src-jvm/test/utest/Parallel.scala diff --git a/utest/jvm/test/src/test/utest/Scheduler.scala b/utest/test/src-jvm/test/utest/Scheduler.scala similarity index 100% rename from utest/jvm/test/src/test/utest/Scheduler.scala rename to utest/test/src-jvm/test/utest/Scheduler.scala diff --git a/utest/jvm/test/src/test/utest/TestUtil.scala b/utest/test/src-jvm/test/utest/TestUtil.scala similarity index 100% rename from utest/jvm/test/src/test/utest/TestUtil.scala rename to utest/test/src-jvm/test/utest/TestUtil.scala diff --git a/utest/native/test/src/test/utest/Scheduler.scala b/utest/test/src-native/test/utest/Scheduler.scala similarity index 100% rename from utest/native/test/src/test/utest/Scheduler.scala rename to utest/test/src-native/test/utest/Scheduler.scala