From f908fca8cf7ba21b9643f625064fbbc8239229d7 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Tue, 6 Aug 2024 21:01:51 +0200 Subject: [PATCH] Manage TestModule dependencies via `build.sc` (#3320) This allows us to detect possible updates easier. Pull request: https://github.com/com-lihaoyi/mill/pull/3320 --- build.sc | 48 +++++++++++++++------ scalalib/src/mill/scalalib/TestModule.scala | 4 +- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/build.sc b/build.sc index 8fc7a268f82..09fca0f4e59 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" @@ -195,6 +195,12 @@ object Deps { val requests = ivy"com.lihaoyi::requests:0.8.3" val sonatypeCentralClient = ivy"com.lumidion::sonatype-central-client-requests:0.3.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", @@ -789,7 +795,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" + ) ) } @@ -2083,7 +2103,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 253ea1b5450..f720fa9a14f 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.github.sbt:junit-interface:0.13.2") + super.ivyDeps() ++ Agg(ivy"${mill.scalalib.api.Versions.sbtTestInterface}") } } @@ -267,7 +267,7 @@ object TestModule { trait Junit5 extends TestModule { override def testFramework: T[String] = "com.github.sbt.junit.jupiter.api.JupiterFramework" override def ivyDeps: T[Agg[Dep]] = T { - super.ivyDeps() ++ Agg(ivy"com.github.sbt.junit:jupiter-interface:0.11.4") + super.ivyDeps() ++ Agg(ivy"${mill.scalalib.api.Versions.jupiterInterface}") } }