From 8bca9234851eb5ee949955e76323827a85c7c069 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Mon, 29 Jul 2024 16:52:58 +0200 Subject: [PATCH 1/3] Mange TestModule dependencies via `build.sc` This allows us to detect possible updates easier. --- build.sc | 60 ++++++++++++++------- scalalib/src/mill/scalalib/TestModule.scala | 4 +- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/build.sc b/build.sc index 0eb8465bec5..9dec708e270 100644 --- a/build.sc +++ b/build.sc @@ -1,15 +1,6 @@ -// plugins and dependencies -import $file.ci.shared -import $file.ci.upload -import $ivy.`org.scalaj::scalaj-http:2.4.2` -import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0` -import $ivy.`com.github.lolgab::mill-mima::0.1.1` -import $ivy.`net.sourceforge.htmlcleaner:htmlcleaner:2.29` -import $ivy.`com.lihaoyi::mill-contrib-buildinfo:` -import $ivy.`com.goyeau::mill-scalafix::0.4.0` - // imports -import com.github.lolgab.mill.mima.{CheckDirection, ProblemFilter, Mima} +import scala.util.chaining._ +import com.github.lolgab.mill.mima.Mima import coursier.maven.MavenRepository import de.tobiasroeser.mill.vcs.version.VcsVersion import com.goyeau.mill.scalafix.ScalafixModule @@ -23,10 +14,19 @@ import mill.scalalib.publish._ import mill.util.Jvm import mill.resolve.SelectMode import mill.contrib.buildinfo.BuildInfo -import mill.scalalib.api.Versions import mill.T import mill.define.Cross +// plugins and dependencies +import $file.ci.shared +import $file.ci.upload +import $ivy.`org.scalaj::scalaj-http:2.4.2` +import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0` +import $ivy.`com.github.lolgab::mill-mima::0.1.1` +import $ivy.`net.sourceforge.htmlcleaner:htmlcleaner:2.29` +import $ivy.`com.lihaoyi::mill-contrib-buildinfo:` +import $ivy.`com.goyeau::mill-scalafix::0.4.0` + object Settings { val pomOrg = "com.lihaoyi" val githubOrg = "com-lihaoyi" @@ -193,6 +193,12 @@ object Deps { val requests = ivy"com.lihaoyi::requests:0.8.3" val sonatypeCentralClient = ivy"com.lumidion::sonatype-central-client-requests:0.2.0" + object RuntimeDeps { + val sbtTestInterface = ivy"com.github.sbt:junit-interface:0.13.2" + val jupiterInterface = ivy"com.github.sbt.junit:jupiter-interface:0.11.4" + def all = Seq(sbtTestInterface, jupiterInterface) + } + /** Used to manage transitive versions. */ val transitiveDeps = Seq( ivy"org.apache.ant:ant:1.10.14", @@ -787,7 +793,21 @@ object scalalib extends MillStableScalaModule { ), BuildInfo.Value("millCompilerBridgeScalaVersions", bridgeScalaVersions.mkString(",")), BuildInfo.Value("millCompilerBridgeVersion", bridgeVersion), - BuildInfo.Value("millVersion", millVersion(), "Mill version.") + BuildInfo.Value("millVersion", millVersion(), "Mill version."), + BuildInfo.Value( + "sbtTestInterface", + Deps.RuntimeDeps.sbtTestInterface.pipe { d => + s"${d.dep.module.organization.value}:${d.dep.module.name.value}:${d.version}" + }, + "Dependency sbt-test-interface" + ), + BuildInfo.Value( + "jupiterInterface", + Deps.RuntimeDeps.jupiterInterface.pipe { d => + s"${d.dep.module.organization.value}:${d.dep.module.name.value}:${d.version}" + }, + "Dependency to jupiter-interface" + ) ) } @@ -1199,13 +1219,13 @@ object example extends MillScalaModule { trait ExampleCrossModuleJava extends ExampleCrossModule { - def upstreamCross(s: String) = s match{ + def upstreamCross(s: String) = s match { case "basicjava" => basic case "javabuilds" => scalabuilds case "javamodule" => scalamodule } - def buildScLines = T{ + def buildScLines = T { val upstreamLines = os.read.lines( upstreamCross(this.millModuleSegments.parts.dropRight(1).last)(crossValue) .testRepoRoot().path / "build.sc" @@ -1215,20 +1235,20 @@ object example extends MillScalaModule { import collection.mutable val groupedLines = mutable.Map.empty[String, mutable.Buffer[String]] var current = Option.empty[String] - lines.foreach{ + lines.foreach { case s"//// SNIPPET:$name" => current = Some(name) groupedLines(name) = mutable.Buffer() case s => groupedLines(current.get).append(s) } - upstreamLines.flatMap{ + upstreamLines.flatMap { case s"//// SNIPPET:$name" => if (name != "END") { current = Some(name) groupedLines(name) - } else{ + } else { current = None Nil } @@ -1245,7 +1265,7 @@ object example extends MillScalaModule { def testRepoRoot: T[PathRef] = T.source(millSourcePath) def compile = example.compile() - def buildScLines = T{ os.read.lines(testRepoRoot().path / "build.sc") } + def buildScLines = T { os.read.lines(testRepoRoot().path / "build.sc") } def forkEnv = super.forkEnv() ++ Map("MILL_EXAMPLE_PARSED" -> upickle.default.write(parsed())) /** @@ -2052,7 +2072,7 @@ val dummyDeps: Seq[Dep] = Seq( Deps.acyclic, Deps.scalacScoverage2Plugin, ivy"com.lihaoyi:::ammonite:${Deps.ammoniteVersion}" -) ++ Deps.transitiveDeps +) ++ Deps.transitiveDeps ++ Deps.RuntimeDeps.all implicit object DepSegment extends Cross.ToSegments[Dep]({ dep => val depString = formatDep(dep) diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index 4b539b463aa..f97e3f97b8d 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -256,7 +256,7 @@ object TestModule { trait Junit4 extends TestModule { override def testFramework: T[String] = "com.novocode.junit.JUnitFramework" override def ivyDeps: T[Agg[Dep]] = T { - super.ivyDeps() ++ Agg(ivy"com.novocode:junit-interface:0.11") + super.ivyDeps() ++ Agg(ivy"${mill.scalalib.api.Versions.sbtTestInterface}") } } @@ -267,7 +267,7 @@ object TestModule { trait Junit5 extends TestModule { override def testFramework: T[String] = "net.aichler.jupiter.api.JupiterFramework" override def ivyDeps: T[Agg[Dep]] = T { - super.ivyDeps() ++ Agg(ivy"net.aichler:jupiter-interface:0.9.0") + super.ivyDeps() ++ Agg(ivy"${mill.scalalib.api.Versions.jupiterInterface}") } } From 50299131f5bc91b4523957c9fdcd9b608eb6f29e Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 1 Aug 2024 00:48:42 +0200 Subject: [PATCH 2/3] Update testframework for Junit5 --- scalalib/src/mill/scalalib/TestModule.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalalib/src/mill/scalalib/TestModule.scala b/scalalib/src/mill/scalalib/TestModule.scala index f97e3f97b8d..f720fa9a14f 100644 --- a/scalalib/src/mill/scalalib/TestModule.scala +++ b/scalalib/src/mill/scalalib/TestModule.scala @@ -265,7 +265,7 @@ object TestModule { * You may want to provide the junit dependency explicitly to use another version. */ trait Junit5 extends TestModule { - override def testFramework: T[String] = "net.aichler.jupiter.api.JupiterFramework" + override def testFramework: T[String] = "com.github.sbt.junit.jupiter.api.JupiterFramework" override def ivyDeps: T[Agg[Dep]] = T { super.ivyDeps() ++ Agg(ivy"${mill.scalalib.api.Versions.jupiterInterface}") } From 60fd273c485a5eaf31a39b0bacec7912847f040d Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 1 Aug 2024 13:43:43 +0200 Subject: [PATCH 3/3] Updated assertion --- example/basicjava/1-simple/build.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/basicjava/1-simple/build.sc b/example/basicjava/1-simple/build.sc index 6526bc27cdd..acdc66126a2 100644 --- a/example/basicjava/1-simple/build.sc +++ b/example/basicjava/1-simple/build.sc @@ -72,7 +72,7 @@ error: argument -t/--text is required ... Test foo.FooTest.testEscaping finished, ... Test foo.FooTest.testSimple finished, ... -Test run finished: 0 failed, 0 ignored, 2 total, ... +Test run foo.FooTest finished: 0 failed, 0 ignored, 2 total, ... > ./mill assembly # bundle classfiles and libraries into a jar for deployment