Skip to content

Commit

Permalink
Update to Mill 0.11.x (#310)
Browse files Browse the repository at this point in the history
* 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-<scalaversion>-<scalaplatform>/` folders for
every scala version and scala platform
* Drop cross-building for Scala.js/Scala-Native version since they only
supported one version anyway
  • Loading branch information
lihaoyi authored Nov 6, 2023
1 parent 8148982 commit 3a7b8ef
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.12
0.11.5
99 changes: 20 additions & 79 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
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"

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(
Expand All @@ -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
}
}
2 changes: 1 addition & 1 deletion mill
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3a7b8ef

Please sign in to comment.