diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1b891487..30f9a2af8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -168,7 +168,7 @@ jobs: echo "-Xmx2g" > .mill-jvm-opts cat .mill-jvm-opts.bak | grep -v Xmx >> .mill-jvm-opts # sometimes running into memory issues when attempting __.publishLocal upfront - for SV in $(./mill scalaVersions); do + for SV in $(./mill dev.scalaVersions); do ./mill -i '__['"$SV"'].compile' ./mill -i '__['"$SV"'].docJar' ./mill -i '__['"$SV"'].publishLocal' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 55471dbfe..7db8f481b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,13 +27,13 @@ jobs: mv .mill-jvm-opts .mill-jvm-opts.bak cat .mill-jvm-opts.bak | grep -v Xmx > .mill-jvm-opts # sometimes running into memory issues when attempting __.publishLocal or __.publishArtifacts upfront - for SV in $(./mill scalaVersions); do + for SV in $(./mill dev.scalaVersions); do ./mill -i '__['"$SV"'].compile' ./mill -i '__['"$SV"'].docJar' ./mill -i '__['"$SV"'].publishLocal' done ./mill -i __.publishLocal - ./mill -i publishSonatype __.publishArtifacts + ./mill -i ci.publishSonatype __.publishArtifacts shell: bash env: PGP_PASSWORD: ${{ secrets.PUBLISH_SECRET_KEY_PASSWORD }} diff --git a/build.sc b/build.sc index 04eec3c90..e2e1c9fed 100644 --- a/build.sc +++ b/build.sc @@ -3,7 +3,7 @@ import $ivy.`io.get-coursier.util::get-cs:0.1.1` import $ivy.`com.github.lolgab::mill-mima::0.0.24` import $ivy.`io.github.alexarchambault.mill::mill-native-image-upload:0.1.24` -import $file.project.deps, deps.{Deps, DepOps, ScalaVersions} +import $file.project.deps, deps.{Deps, DepOps, ScalaVersions, Versions} import $file.project.jupyterserver, jupyterserver.{jupyterConsole => jupyterConsole0, jupyterServer} import $file.scripts.website0.Website, Website.Relativize import $file.project.settings, settings.{ @@ -33,17 +33,19 @@ import _root_.scala.concurrent.duration._ import _root_.scala.util.Properties // Tell mill modules are under modules/ -implicit def millModuleBasePath: define.BasePath = - define.BasePath(super.millModuleBasePath.value / "modules") +implicit def millModuleBasePath: define.Ctx.BasePath = + define.Ctx.BasePath(super.millModuleBasePath.value / "modules") -class LoggerScala2Macros(val crossScalaVersion: String) extends AlmondModule { +trait LoggerScala2Macros extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def ivyDeps = T { val sv = scalaVersion() Agg(Deps.scalaReflect(sv)) } } -class Logger(val crossScalaVersion: String) extends AlmondModule { +trait Logger extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def supports3 = true def moduleDeps = Seq( shared.`logger-scala2-macros`() @@ -55,10 +57,11 @@ class Logger(val crossScalaVersion: String) extends AlmondModule { else Agg(ivy"org.scala-lang:scala3-library_3:${scalaVersion()}") scalaReflect } - object test extends Tests with AlmondTestModule + object test extends CrossSbtModuleTests with AlmondTestModule } -class Channels(val crossScalaVersion: String) extends AlmondModule with Mima { +trait Channels extends Cross.Module[String] with AlmondModule with Mima { + def crossScalaVersion = crossValue def moduleDeps = Seq( shared.logger() ) @@ -66,10 +69,11 @@ class Channels(val crossScalaVersion: String) extends AlmondModule with Mima { Deps.fs2(crossScalaVersion), Deps.jeromq ) - object test extends Tests with AlmondTestModule + object test extends CrossSbtModuleTests with AlmondTestModule } -class Protocol(val crossScalaVersion: String) extends AlmondModule { +trait Protocol extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def moduleDeps = Seq( shared.channels() ) @@ -80,12 +84,15 @@ class Protocol(val crossScalaVersion: String) extends AlmondModule { Deps.scalaReflect(scalaVersion()), Deps.jsoniterScalaMacros.withConfiguration("provided") ) - object test extends Tests with AlmondTestModule + object test extends CrossSbtModuleTests with AlmondTestModule } -class InterpreterApi(val crossScalaVersion: String) extends AlmondModule with Mima +trait InterpreterApi extends Cross.Module[String] with AlmondModule with Mima { + def crossScalaVersion = crossValue +} -class Interpreter(val crossScalaVersion: String) extends AlmondModule { +trait Interpreter extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def moduleDeps = Seq( shared.`interpreter-api`(), shared.protocol() @@ -96,10 +103,11 @@ class Interpreter(val crossScalaVersion: String) extends AlmondModule { Deps.scalatags.applyBinaryVersion213_3(scalaVersion()), Deps.slf4jNop ) - object test extends Tests with AlmondTestModule + object test extends CrossSbtModuleTests with AlmondTestModule } -class Kernel(val crossScalaVersion: String) extends AlmondModule { +trait Kernel extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def moduleDeps = Seq( shared.interpreter() ) @@ -112,7 +120,7 @@ class Kernel(val crossScalaVersion: String) extends AlmondModule { Deps.coursierApi, Deps.fs2(crossScalaVersion) ) - object test extends Tests with AlmondTestModule { + object test extends CrossSbtModuleTests with AlmondTestModule { def moduleDeps = super.moduleDeps ++ Seq( shared.interpreter().test, shared.`test-kit`() @@ -120,13 +128,15 @@ class Kernel(val crossScalaVersion: String) extends AlmondModule { } } -class Test(val crossScalaVersion: String) extends AlmondModule { +trait Test extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def moduleDeps = Seq( shared.`interpreter-api`() ) } -class JupyterApi(val crossScalaVersion: String) extends AlmondModule with Mima { +trait JupyterApi extends Cross.Module[String] with AlmondModule with Mima { + def crossScalaVersion = crossValue def moduleDeps = Seq( shared.`interpreter-api`() ) @@ -135,8 +145,9 @@ class JupyterApi(val crossScalaVersion: String) extends AlmondModule with Mima { ) } -class ScalaKernelApi(val crossScalaVersion: String) extends AlmondModule with DependencyListResource +trait ScalaKernelApi extends Cross.Module[String] with AlmondModule with DependencyListResource with ExternalSources with PropertyFile with Mima with Bloop.Module { + def crossScalaVersion = crossValue def skipBloop = !ScalaVersions.binaries.contains(crossScalaVersion) def crossFullScalaVersion = true def moduleDeps = @@ -184,7 +195,8 @@ class ScalaKernelApi(val crossScalaVersion: String) extends AlmondModule with De } } -class ScalaInterpreter(val crossScalaVersion: String) extends AlmondModule with Bloop.Module { +trait ScalaInterpreter extends Cross.Module[String] with AlmondModule with Bloop.Module { + def crossScalaVersion = crossValue def skipBloop = !ScalaVersions.binaries.contains(crossScalaVersion) def crossFullScalaVersion = true def supports3 = true @@ -234,7 +246,7 @@ class ScalaInterpreter(val crossScalaVersion: String) extends AlmondModule with else Nil scala213Options } - object test extends Tests with AlmondTestModule { + object test extends CrossSbtModuleTests with AlmondTestModule { def moduleDeps = { val rx = if (crossScalaVersion.startsWith("2.12.")) Seq(scala.`almond-rx`()) @@ -269,8 +281,9 @@ class ScalaInterpreter(val crossScalaVersion: String) extends AlmondModule with } } -class ScalaKernel(val crossScalaVersion: String) extends AlmondModule with ExternalSources +trait ScalaKernel extends Cross.Module[String] with AlmondModule with ExternalSources with BootstrapLauncher with Bloop.Module { + def crossScalaVersion = crossValue def skipBloop = !ScalaVersions.binaries.contains(crossScalaVersion) def crossFullScalaVersion = true def moduleDeps = @@ -289,7 +302,7 @@ class ScalaKernel(val crossScalaVersion: String) extends AlmondModule with Exter Deps.classPathUtil, Deps.scalafmtDynamic.withDottyCompat(crossScalaVersion) ) - object test extends Tests with AlmondTestModule { + object test extends CrossSbtModuleTests with AlmondTestModule { def moduleDeps = super.moduleDeps ++ Seq( scala.`scala-interpreter`().test ) @@ -357,7 +370,8 @@ class ScalaKernel(val crossScalaVersion: String) extends AlmondModule with Exter // depend on the more complex 2.13-targeting-scala-3 module like // scala-kernel-cross-3.0.2_2.13.7. The former follows the same name pattern // as their Scala 2 counterparts, and are more convenient to write down for end users. -class ScalaKernelHelper(val crossScalaVersion: String) extends AlmondModule with Bloop.Module { +trait ScalaKernelHelper extends Cross.Module[String] with AlmondModule with Bloop.Module { + def crossScalaVersion = crossValue def skipBloop = !ScalaVersions.binaries.contains(crossScalaVersion) def crossFullScalaVersion = true def supports3 = true @@ -367,7 +381,8 @@ class ScalaKernelHelper(val crossScalaVersion: String) extends AlmondModule with ) } -class CoursierLogger(val crossScalaVersion: String) extends AlmondModule { +trait CoursierLogger extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def supports3 = true def moduleDeps = super.moduleDeps ++ Seq( shared.`interpreter-api`(), @@ -379,7 +394,8 @@ class CoursierLogger(val crossScalaVersion: String) extends AlmondModule { ) } -class SharedDirectives(val crossScalaVersion: String) extends AlmondModule { +trait SharedDirectives extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def supports3 = true def ivyDeps = super.ivyDeps() ++ Agg( Deps.directiveHandler, @@ -422,8 +438,9 @@ trait Launcher extends AlmondSimpleModule with BootstrapLauncher with PropertyFi } } -class ScalaKernelApiHelper(val crossScalaVersion: String) extends AlmondModule with ExternalSources +trait ScalaKernelApiHelper extends Cross.Module[String] with AlmondModule with ExternalSources with Bloop.Module { + def crossScalaVersion = crossValue def skipBloop = !ScalaVersions.binaries.contains(crossScalaVersion) def crossFullScalaVersion = true def supports3 = true @@ -433,7 +450,8 @@ class ScalaKernelApiHelper(val crossScalaVersion: String) extends AlmondModule w ) } -class AlmondScalaPy(val crossScalaVersion: String) extends AlmondModule with Mima { +trait AlmondScalaPy extends Cross.Module[String] with AlmondModule with Mima { + def crossScalaVersion = crossValue def ivyDeps = Agg( Deps.jvmRepr ) @@ -442,7 +460,8 @@ class AlmondScalaPy(val crossScalaVersion: String) extends AlmondModule with Mim ) } -class AlmondRx(val crossScalaVersion: String) extends AlmondModule with Mima { +trait AlmondRx extends Cross.Module[String] with AlmondModule with Mima { + def crossScalaVersion = crossValue def compileModuleDeps = Seq( scala.`scala-kernel-api`() ) @@ -451,7 +470,8 @@ class AlmondRx(val crossScalaVersion: String) extends AlmondModule with Mima { ) } -class Echo(val crossScalaVersion: String) extends AlmondModule { +trait Echo extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def moduleDeps = Seq( shared.kernel() ) @@ -459,14 +479,15 @@ class Echo(val crossScalaVersion: String) extends AlmondModule { Deps.caseApp.withDottyCompat(crossScalaVersion) ) def propertyFilePath = "almond/echo.properties" - object test extends Tests with AlmondTestModule { + object test extends this.CrossSbtModuleTests with AlmondTestModule { def moduleDeps = super.moduleDeps ++ Seq( shared.test() ) } } -class ToreeHooks(val crossScalaVersion: String) extends AlmondModule { +trait ToreeHooks extends Cross.Module[String] with AlmondModule { + def crossScalaVersion = crossValue def supports3 = true def compileModuleDeps = super.compileModuleDeps ++ Seq( scala.`scala-kernel-api`(ScalaVersions.binary(crossScalaVersion)) @@ -474,40 +495,40 @@ class ToreeHooks(val crossScalaVersion: String) extends AlmondModule { } object shared extends Module { - object `logger-scala2-macros` extends Cross[LoggerScala2Macros](ScalaVersions.binaries: _*) - object logger extends Cross[Logger](ScalaVersions.binaries: _*) - object channels extends Cross[Channels](ScalaVersions.binaries: _*) - object protocol extends Cross[Protocol](ScalaVersions.binaries: _*) - object `interpreter-api` extends Cross[InterpreterApi](ScalaVersions.binaries: _*) - object interpreter extends Cross[Interpreter](ScalaVersions.binaries: _*) - object kernel extends Cross[Kernel](ScalaVersions.binaries: _*) - object test extends Cross[Test](ScalaVersions.binaries: _*) - object `test-kit` extends Cross[TestKit](ScalaVersions.all: _*) + object `logger-scala2-macros` extends Cross[LoggerScala2Macros](ScalaVersions.binaries) + object logger extends Cross[Logger](ScalaVersions.binaries) + object channels extends Cross[Channels](ScalaVersions.binaries) + object protocol extends Cross[Protocol](ScalaVersions.binaries) + object `interpreter-api` extends Cross[InterpreterApi](ScalaVersions.binaries) + object interpreter extends Cross[Interpreter](ScalaVersions.binaries) + object kernel extends Cross[Kernel](ScalaVersions.binaries) + object test extends Cross[Test](ScalaVersions.binaries) + object `test-kit` extends Cross[TestKit](ScalaVersions.all) } // FIXME Can't use 'scala' because of macro hygiene issues in some mill macros object scala extends Module { - implicit def millModuleBasePath: define.BasePath = - define.BasePath(super.millModuleBasePath.value / os.up / "scala") - object `jupyter-api` extends Cross[JupyterApi](ScalaVersions.binaries: _*) - object `scala-kernel-api` extends Cross[ScalaKernelApi](ScalaVersions.all: _*) + implicit def millModuleBasePath: define.Ctx.BasePath = + define.Ctx.BasePath(super.millModuleBasePath.value / os.up / "scala") + object `jupyter-api` extends Cross[JupyterApi](ScalaVersions.binaries) + object `scala-kernel-api` extends Cross[ScalaKernelApi](ScalaVersions.all) object `scala-kernel-api-helper` - extends Cross[ScalaKernelApiHelper](ScalaVersions.all.filter(_.startsWith("3.")): _*) - object `scala-interpreter` extends Cross[ScalaInterpreter](ScalaVersions.all: _*) - object `scala-kernel` extends Cross[ScalaKernel](ScalaVersions.all: _*) + extends Cross[ScalaKernelApiHelper](ScalaVersions.all.filter(_.startsWith("3."))) + object `scala-interpreter` extends Cross[ScalaInterpreter](ScalaVersions.all) + object `scala-kernel` extends Cross[ScalaKernel](ScalaVersions.all) object `scala-kernel-helper` - extends Cross[ScalaKernelHelper](ScalaVersions.all.filter(_.startsWith("3.")): _*) - object `coursier-logger` extends Cross[CoursierLogger](ScalaVersions.binaries: _*) + extends Cross[ScalaKernelHelper](ScalaVersions.all.filter(_.startsWith("3."))) + object `coursier-logger` extends Cross[CoursierLogger](ScalaVersions.binaries) object `shared-directives` - extends Cross[SharedDirectives]("2.12.15" +: ScalaVersions.binaries: _*) + extends Cross[SharedDirectives]("2.12.15" +: ScalaVersions.binaries) object launcher extends Launcher - object `almond-scalapy` extends Cross[AlmondScalaPy](ScalaVersions.binaries: _*) - object `almond-rx` extends Cross[AlmondRx](ScalaVersions.scala212, ScalaVersions.scala213) + object `almond-scalapy` extends Cross[AlmondScalaPy](ScalaVersions.binaries) + object `almond-rx` extends Cross[AlmondRx](Seq(ScalaVersions.scala212, ScalaVersions.scala213)) - object `toree-hooks` extends Cross[ToreeHooks](ScalaVersions.binaries: _*) + object `toree-hooks` extends Cross[ToreeHooks](ScalaVersions.binaries) - object `test-definitions` extends Cross[TestDefinitions](ScalaVersions.all: _*) - object `local-repo` extends Cross[KernelLocalRepo](ScalaVersions.all: _*) + object `test-definitions` extends Cross[TestDefinitions](ScalaVersions.all) + object `local-repo` extends Cross[KernelLocalRepo](ScalaVersions.all) object integration extends Integration object examples extends Examples @@ -517,7 +538,7 @@ trait Examples extends SbtModule { private def examplesScalaVersion = "2.12.12" private def baseRepoRoot = os.rel / "out" / "repo" def scalaVersion = ScalaVersions.scala3Latest - object test extends Tests { + object test extends SbtModuleTests { def testFramework = "munit.Framework" def ivyDeps = T { super.ivyDeps() ++ Agg( @@ -542,7 +563,8 @@ trait Examples extends SbtModule { } } -class TestKit(val crossScalaVersion: String) extends CrossSbtModule with Bloop.Module { +trait TestKit extends Cross.Module[String] with CrossSbtModule with Bloop.Module { + def crossScalaVersion = crossValue def skipBloop = !ScalaVersions.binaries.contains(crossScalaVersion) def moduleDeps = if (crossScalaVersion.startsWith("3.")) @@ -560,7 +582,8 @@ class TestKit(val crossScalaVersion: String) extends CrossSbtModule with Bloop.M ) } -class TestDefinitions(val crossScalaVersion: String) extends CrossSbtModule with Bloop.Module { +trait TestDefinitions extends Cross.Module[String] with CrossSbtModule with Bloop.Module { + def crossScalaVersion = crossValue def skipBloop = !ScalaVersions.binaries.contains(crossScalaVersion) def moduleDeps = super.moduleDeps ++ Seq( @@ -574,7 +597,8 @@ class TestDefinitions(val crossScalaVersion: String) extends CrossSbtModule with } } -class KernelLocalRepo(val testScalaVersion: String) extends LocalRepo { +trait KernelLocalRepo extends Cross.Module[String] with LocalRepo { + def testScalaVersion = crossValue def stubsModules = { val extra = if (testScalaVersion.startsWith("2.")) Nil @@ -625,7 +649,7 @@ trait Integration extends SbtModule { Deps.pprint ) - object test extends Tests with TestCommand { + object test extends SbtModuleTests with TestCommand { def testFramework = "munit.Framework" def forkArgs = T { scala.`local-repo`(ScalaVersions.scala212).localRepo() @@ -651,7 +675,7 @@ trait Integration extends SbtModule { } } -object echo extends Cross[Echo](ScalaVersions.binaries: _*) +object echo extends Cross[Echo](ScalaVersions.binaries) object docs extends ScalaModule with AlmondRepositories { private def scalaVersion0 = ScalaVersions.scala213 @@ -759,89 +783,76 @@ object docs extends ScalaModule with AlmondRepositories { } } -def jupyter0(args: Seq[String], fast: Boolean, console: Boolean = false) = { - val (sv, args0) = args match { - case Seq(sv, rem @ _*) if sv.startsWith("2.") || sv.startsWith("3.") => - (sv, rem) - case _ => (ScalaVersions.scala213, args) - } - val launcher = - if (fast) scala.`scala-kernel`(sv).fastLauncher - else scala.`scala-kernel`(sv).launcher - val specialLauncher = - if (fast) scala.launcher.fastLauncher - else scala.launcher.launcher - T.command { - val jupyterDir = T.ctx().dest / "jupyter" - val launcher0 = launcher().path.toNIO - val specialLauncher0 = specialLauncher().path.toNIO - if (console) - jupyterConsole0(launcher0, specialLauncher0, jupyterDir.toNIO, args0) - else - jupyterServer(launcher0, specialLauncher0, jupyterDir.toNIO, args0) - } -} +object dev extends Module { -def jupyter(args: String*) = - jupyter0(args, fast = false) + def jupyter0(args: Seq[String], fast: Boolean, console: Boolean = false) = { + val (sv, args0) = args match { + case Seq(sv, rem @ _*) if sv.startsWith("2.") || sv.startsWith("3.") => + (sv, rem) + case _ => (ScalaVersions.scala213, args) + } + val launcher = + if (fast) scala.`scala-kernel`(sv).fastLauncher + else scala.`scala-kernel`(sv).launcher + val specialLauncher = + if (fast) scala.launcher.fastLauncher + else scala.launcher.launcher + T.command { + val jupyterDir = T.ctx().dest / "jupyter" + val launcher0 = launcher().path.toNIO + val specialLauncher0 = specialLauncher().path.toNIO + if (console) + jupyterConsole0(launcher0, specialLauncher0, jupyterDir.toNIO, args0) + else + jupyterServer(launcher0, specialLauncher0, jupyterDir.toNIO, args0) + } + } -def jupyterFast(args: String*) = - jupyter0(args, fast = true) + def jupyter(args: String*) = + jupyter0(args, fast = false) -def jupyterConsole(args: String*) = - jupyter0(args, fast = false, console = true) + def jupyterFast(args: String*) = + jupyter0(args, fast = true) -def jupyterConsoleFast(args: String*) = - jupyter0(args, fast = true, console = true) + def jupyterConsole(args: String*) = + jupyter0(args, fast = false, console = true) -def publishSonatype(tasks: mill.main.Tasks[PublishModule.PublishData]) = - T.command { - val timeout = 10.minutes - val credentials = sys.env("SONATYPE_USERNAME") + ":" + sys.env("SONATYPE_PASSWORD") - val pgpPassword = sys.env("PGP_PASSWORD") - val data = T.sequence(tasks.value)() + def jupyterConsoleFast(args: String*) = + jupyter0(args, fast = true, console = true) - settings.publishSonatype( - credentials = credentials, - pgpPassword = pgpPassword, - data = data, - timeout = timeout, - log = T.ctx().log - ) + def scala212() = T.command { + println(ScalaVersions.scala212) + } + def scala213() = T.command { + println(ScalaVersions.scala213) + } + def scala3() = T.command { + println(ScalaVersions.scala3Latest) + } + def scalaVersions() = T.command { + for (sv <- ScalaVersions.all) + println(sv) } -def scala212() = T.command { - println(ScalaVersions.scala212) -} -def scala213() = T.command { - println(ScalaVersions.scala213) -} -def scala3() = T.command { - println(ScalaVersions.scala3Latest) -} -def scalaVersions() = T.command { - for (sv <- ScalaVersions.all) - println(sv) -} - -def launcher(scalaVersion: String = ScalaVersions.scala213) = T.command { - val launcher = scala.`scala-kernel`(scalaVersion).launcher().path.toNIO - println(launcher) -} + def launcher(scalaVersion: String = ScalaVersions.scala213) = T.command { + val launcher = scala.`scala-kernel`(scalaVersion).launcher().path.toNIO + println(launcher) + } -def specialLauncher(scalaVersion: String = ScalaVersions.scala213) = T.command { - val launcher = scala.launcher.launcher().path.toNIO - println(launcher) -} + def specialLauncher(scalaVersion: String = ScalaVersions.scala213) = T.command { + val launcher = scala.launcher.launcher().path.toNIO + println(launcher) + } -def launcherFast(scalaVersion: String = ScalaVersions.scala213) = T.command { - val launcher = scala.`scala-kernel`(scalaVersion).fastLauncher().path.toNIO - println(launcher) -} + def launcherFast(scalaVersion: String = ScalaVersions.scala213) = T.command { + val launcher = scala.`scala-kernel`(scalaVersion).fastLauncher().path.toNIO + println(launcher) + } -def specialLauncherFast(scalaVersion: String = ScalaVersions.scala213) = T.command { - val launcher = scala.launcher.fastLauncher().path.toNIO - println(launcher) + def specialLauncherFast(scalaVersion: String = ScalaVersions.scala213) = T.command { + val launcher = scala.launcher.fastLauncher().path.toNIO + println(launcher) + } } def ghOrg = "almond-sh" @@ -883,6 +894,22 @@ object ci extends Module { launchers: _* ) } + + def publishSonatype(tasks: mill.main.Tasks[PublishModule.PublishData]) = + T.command { + val timeout = 10.minutes + val credentials = sys.env("SONATYPE_USERNAME") + ":" + sys.env("SONATYPE_PASSWORD") + val pgpPassword = sys.env("PGP_PASSWORD") + val data = T.sequence(tasks.value)() + + settings.publishSonatype( + credentials = credentials, + pgpPassword = pgpPassword, + data = data, + timeout = timeout, + log = T.ctx().log + ) + } } object dummy extends Module { diff --git a/docs/pages/dev-from-sources.md b/docs/pages/dev-from-sources.md index 49e7bc603..747946639 100644 --- a/docs/pages/dev-from-sources.md +++ b/docs/pages/dev-from-sources.md @@ -35,7 +35,7 @@ We list below useful commands, to help get you started using mill to build almon ## Run a Jupyter notebook server without installing a kernel ```text -$ ./mill -i jupyterFast +$ ./mill -i dev.jupyterFast ``` This should @@ -46,16 +46,16 @@ From the JupyterLab instance, select the kernel "Scala (sources)". Optionally, pass a Scala version and / or JupyterLab options, like ```text -$ ./mill -i jupyterFast 2.12.13 -$ ./mill -i jupyterFast --ip=192.168.0.1 -$ ./mill -i jupyterFast 2.12.13 --ip=192.168.0.1 +$ ./mill -i dev.jupyterFast 2.12.13 +$ ./mill -i dev.jupyterFast --ip=192.168.0.1 +$ ./mill -i dev.jupyterFast 2.12.13 --ip=192.168.0.1 ``` (If specified, the Scala version needs to be passed first.) ## Build a kernel launcher ```text -$ ./mill launcherFast +$ ./mill dev.launcherFast ``` Once done building, this should print the path to the kernel launcher, like @@ -63,7 +63,7 @@ Once done building, this should print the path to the kernel launcher, like Optionally, pass a Scala version, like ```text -$ ./mill launcherFast 2.12.13 +$ ./mill dev.launcherFast 2.12.13 ``` You can then run that launcher to install it on your system: @@ -76,18 +76,18 @@ Pass `--help` or see [this page](install-options.md) for the available options. You can re-build a launcher upon source changes with ```text -$ ./mill -w launcherFast +$ ./mill -w dev.launcherFast ``` If you [ran a JupyterLab server from the almond sources](#run-a-jupyter-notebook-server-without-installing-a-kernel), you can restart the kernel from a notebook via JupyterLab to pick a newly built launcher. If you passed a Scala -version to `./mill jupyter`, beware to pass the same version to `./mill -w launcher`. +version to `./mill dev.jupyter`, beware to pass the same version to `./mill -w dev.launcher`. ## Useful commands ### List available Scala versions ```text -$ ./mill scalaVersions +$ ./mill dev.scalaVersions 2.13.4 2.13.3 … @@ -95,13 +95,13 @@ $ ./mill scalaVersions ### Print the latest supported Scala 2.13 version ```text -$ ./mill scala213 +$ ./mill dev.scala213 2.13.4 ``` ### Print the latest supported Scala 2.12 version ```text -$ ./mill scala212 +$ ./mill dev.scala212 2.12.13 ``` diff --git a/project/settings.sc b/project/settings.sc index 81add5b0b..dc883d326 100644 --- a/project/settings.sc +++ b/project/settings.sc @@ -8,6 +8,7 @@ import java.nio.file.{Files, Path} import java.util.{Arrays, Properties} import mill._, scalalib.{CrossSbtModule => _, _} +import mill.scalalib.api.ZincWorkerUtil import scala.annotation.tailrec import scala.concurrent.duration._ @@ -34,20 +35,27 @@ lazy val buildVersion = { } // Adapted from https://github.com/lihaoyi/mill/blob/0.9.3/scalalib/src/MiscModule.scala/#L80-L100 +// and https://github.com/com-lihaoyi/mill/blob/c75e29c78cfc3c1e04776978bfc8e5697f8ca1aa/scalalib/src/mill/scalalib/CrossSbtModule.scala#L7 // Compared to the original code, we ensure `scalaVersion()` rather than `crossScalaVersion` is // used when computing paths, as the former is always a valid Scala version, // while the latter can be a 3.x version while we compile using Scala 2.x // (and later rely on dotty compatibility to mix Scala 2 / Scala 3 modules). trait CrossSbtModule extends mill.scalalib.SbtModule with mill.scalalib.CrossModuleBase { outer => - override def sources = T.sources { - super.sources() ++ - mill.scalalib.CrossModuleBase.scalaVersionPaths( - scalaVersion(), - s => millSourcePath / 'src / 'main / s"scala-$s" + def sources = T.sources { + super.sources() ++ scalaVersionDirectoryNames.map(s => + PathRef(millSourcePath / "src" / "main" / s"scala-$s") + ) + } + trait CrossSbtModuleTests extends SbtModuleTests { + override def millSourcePath = outer.millSourcePath + def sources = T.sources { + super.sources() ++ scalaVersionDirectoryNames.map(s => + PathRef(millSourcePath / "src" / "test" / s"scala-$s") ) - + } } + trait Tests extends CrossSbtModuleTests } trait AlmondRepositories extends CoursierModule { @@ -74,9 +82,9 @@ trait AlmondPublishModule extends PublishModule { } trait ExternalSources extends CrossSbtModule { - def allIvyDeps = T(transitiveIvyDeps() ++ scalaLibraryIvyDeps()) + // def allIvyDeps = T((transitiveIvyDeps(): Agg[Dep]) ++ (scalaLibraryIvyDeps(): Agg[Dep])) def externalSources = T { - resolveDeps(allIvyDeps, sources = true)() + resolveDeps(T.task { transitiveCompileIvyDeps() ++ transitiveIvyDeps() }, sources = true)() } } @@ -152,11 +160,12 @@ trait AlmondArtifactName extends SbtModule { trait AlmondScala2Or3Module extends CrossSbtModule { def crossScalaVersion: String def supports3: Boolean = false - def scalaVersion = T { + private def actualScalaVersion = { if (crossScalaVersion.startsWith("3.") && !supports3) ScalaVersions.cross2_3Version(crossScalaVersion) else crossScalaVersion } + def scalaVersion = T(actualScalaVersion) def useCrossSuffix = T { crossScalaVersion.startsWith("3.") && !scalaVersion().startsWith("3.") } @@ -170,6 +179,8 @@ trait AlmondScala2Or3Module extends CrossSbtModule { else Nil tastyReaderOptions } + override def scalaVersionDirectoryNames = + ZincWorkerUtil.matchingVersions(actualScalaVersion) } trait AlmondScalacOptions extends ScalaModule { @@ -234,27 +245,10 @@ trait AlmondModule } def transitiveIvyDeps = T { super.transitiveIvyDeps().map { dep => - def isScala3Lib = - dep.dep.module.organization.value == "org.scala-lang" && - dep.dep.module.name.value == "scala3-library" && - (dep.cross match { - case _: CrossVersion.Binary => true - case _ => false - }) - def isScala3JarWithSuffix = + val isScala3JarWithSuffix = dep.dep.module.organization.value == "org.scala-lang" && dep.dep.module.name.value.startsWith("scala3-") - if (isScala3Lib) - dep.copy( - dep = dep.dep.withModule( - dep.dep.module.withName( - coursier.ModuleName(dep.dep.module.name.value + "_3") - ) - ), - cross = CrossVersion.empty(dep.cross.platformed), - force = false - ) - else if (isScala3JarWithSuffix) + if (isScala3JarWithSuffix) dep.copy(force = false) else dep } @@ -296,39 +290,14 @@ trait AlmondTestModule } def transitiveIvyDeps = T { super.transitiveIvyDeps().map { dep => - def isScala3Lib = - dep.dep.module.organization.value == "org.scala-lang" && - dep.dep.module.name.value == "scala3-library" && - (dep.cross match { - case _: CrossVersion.Binary => true - case _ => false - }) - def isScala3JarWithSuffix = + val isScala3JarWithSuffix = dep.dep.module.organization.value == "org.scala-lang" && dep.dep.module.name.value.startsWith("scala3-") - if (isScala3Lib) - dep.copy( - dep = dep.dep.withModule( - dep.dep.module.withName( - coursier.ModuleName(dep.dep.module.name.value + "_3") - ) - ), - cross = CrossVersion.empty(dep.cross.platformed), - force = false - ) - else if (isScala3JarWithSuffix) + if (isScala3JarWithSuffix) dep.copy(force = false) else dep } } - - def sources = T.sources { - super.sources() ++ - mill.scalalib.CrossModuleBase.scalaVersionPaths( - scalaVersion(), - s => millSourcePath / "src" / "test" / s"scala-$s" - ) - } } trait BootstrapLauncher extends SbtModule { @@ -516,9 +485,10 @@ trait DependencyListResource extends CrossSbtModule { def depResourcesDir = T.persistent { val (_, res) = Lib.resolveDependenciesMetadata( repositoriesTask(), - resolveCoursierDependency().apply(_), transitiveIvyDeps(), - Some(mapDependencies()) + Some(mapDependencies()), + customizer = resolutionCustomizer(), + coursierCacheCustomizer = coursierCacheCustomizer() ) val content = res .orderedDependencies @@ -712,7 +682,7 @@ trait TestCommand extends TestModule { import mill.testrunner.TestRunner val globSelectors = Nil - val outputPath = os.pwd / "test-output.json" + val outputPath = T.dest / "out.json" val useArgsFile = testUseArgsFile() val (jvmArgs, props: Map[String, String]) = @@ -732,34 +702,31 @@ trait TestCommand extends TestModule { else forkArgs() -> Map() - os.remove(outputPath) - - val testArgs = TestRunner.TestArgs( + val testArgs = mill.testrunner.TestArgs( framework = testFramework(), - classpath = runClasspath().map(_.path.toString()), + classpath = runClasspath().map(_.path), arguments = args, sysProps = props, - outputPath = outputPath.toString(), + outputPath = outputPath, colored = T.log.colored, - testCp = compile().classes.path.toString(), - homeStr = T.home.toString(), + testCp = compile().classes.path, + home = T.home, globSelectors = globSelectors ) - val mainArgs = - if (useArgsFile) { - val argsFile = T.dest / "testargs" - Seq(testArgs.writeArgsFile(argsFile)) - } - else - testArgs.toArgsSeq + val testRunnerClasspathArg = zincWorker().scalalibClasspath() + .map(_.path.toNIO.toUri.toURL) + .mkString(",") - val envArgs = forkEnv() + val argsFile = T.dest / "testargs" + os.write(argsFile, upickle.default.write(testArgs)) + val mainArgs = Seq(testRunnerClasspathArg, argsFile.toString) + val envArgs = forkEnv() val workingDir = forkWorkingDir() val args0 = jvmSubprocessCommand( - mainClass = "mill.testrunner.TestRunner", - classPath = zincWorker.scalalibClasspath().map(_.path), + mainClass = "mill.testrunner.entrypoint.TestRunnerMain", + classPath = (runClasspath() ++ zincWorker().testrunnerEntrypointClasspath()).map(_.path), jvmArgs = jvmArgs, envArgs = envArgs, mainArgs = mainArgs, diff --git a/scripts/update-docker-images.sh b/scripts/update-docker-images.sh index f7c0c55f1..a5db07864 100755 --- a/scripts/update-docker-images.sh +++ b/scripts/update-docker-images.sh @@ -3,9 +3,9 @@ set -eu # TODO Convert to a mill task -SCALA212_VERSION="$(./mill scala212)" -SCALA213_VERSION="$(./mill scala213)" -SCALA3_VERSION="$(./mill scala3)" +SCALA212_VERSION="$(./mill dev.scala212)" +SCALA213_VERSION="$(./mill dev.scala213)" +SCALA3_VERSION="$(./mill dev.scala3)" DOCKER_REPO=almondsh/almond