Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Nov 6, 2023
1 parent 8148982 commit 0016c74
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 61 deletions.
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
78 changes: 19 additions & 59 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
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 scalaVersions = "2.12.17" :: "2.13.10" :: "3.3.1" :: communityBuildDottyVersion

val scalaJSVersions = scalaVersions.map((_, "1.12.0"))
val scalaNativeVersions = scalaVersions.map((_, "0.4.9"))
val scalaNativeVersions = scalaVersions.map((_, "0.4.16"))

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()
if(crossScalaVersion.startsWith("3.")) Agg.empty[Dep] else super.mimaPreviousArtifacts()

def publishVersion = VcsVersion.vcsState().format()

Expand All @@ -41,92 +40,53 @@ 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


trait UtestTestModule extends ScalaModule with TestModule {
def crossScalaVersion: String
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 with ScalaModule with UtestModule {
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{
object test extends ScalaTests with UtestTestModule{
val crossScalaVersion = JvmUtestModule.this.crossScalaVersion
}
}

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](scalaJSVersions)
trait JsUtestModule extends UtestMainModule with ScalaJSModule with UtestModule with Cross.Module2[String, String]{
def crossJSVersion = crossValue2
def ivyDeps = Agg(
ivy"org.scala-js::scalajs-test-interface:$crossJSVersion".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{
object test extends ScalaJSTests with UtestTestModule{
def offset = os.up
val crossScalaVersion = JsUtestModule.this.crossScalaVersion
}
}

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](scalaNativeVersions)
trait NativeUtestModule extends UtestMainModule with ScalaNativeModule with UtestModule with Cross.Module2[String, String]{
def crossScalaNativeVersion = crossValue2
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"org.scala-native::test-interface::$crossScalaNativeVersion"
)

def scalaNativeVersion = crossScalaNativeVersion
object test extends Tests with UtestTestModule{
def offset = os.up
object test extends ScalaNativeTests with UtestTestModule{
val crossScalaVersion = NativeUtestModule.this.crossScalaVersion
}
}
Expand Down
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 0016c74

Please sign in to comment.