diff --git a/scalalib/src/mill/scalalib/CrossModuleBase.scala b/scalalib/src/mill/scalalib/CrossModuleBase.scala index d8d9c81ffe3..b0942dd6d41 100644 --- a/scalalib/src/mill/scalalib/CrossModuleBase.scala +++ b/scalalib/src/mill/scalalib/CrossModuleBase.scala @@ -22,7 +22,7 @@ trait CrossModuleBase extends ScalaModule with Cross.Module[String] { crossScalaVersion .split('.') .inits - .takeWhile(_.length > 1) + .takeWhile(_.length > (if(ZincWorkerUtil.isScala3(crossScalaVersion)) 0 else 1)) .flatMap(prefix => c.crossModules .find(_.crossScalaVersion.split('.').startsWith(prefix)) diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala index cdc3e0d71fb..fa4abf28537 100644 --- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala +++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala @@ -22,6 +22,8 @@ object HelloWorldTests extends TestSuite { val scala2123Version = "2.12.3" val scala212Version = sys.props.getOrElse("TEST_SCALA_2_12_VERSION", ???) val scala213Version = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???) + val scala32Version = sys.props.getOrElse("TEST_SCALA_3_2_VERSION", ???) + val scala33Version = sys.props.getOrElse("TEST_SCALA_3_3_VERSION", ???) val zincVersion = sys.props.getOrElse("TEST_ZINC_VERSION", ???) trait HelloBase extends TestUtil.BaseModule { @@ -59,6 +61,15 @@ object HelloWorldTests extends TestSuite { ) trait HelloWorldCross extends CrossScalaModule } + object CrossModuleDeps extends HelloBase { + object stable extends Cross[Stable](scala212Version, scala32Version) + trait Stable extends CrossScalaModule + + object cuttingEdge extends Cross[CuttingEdge](scala213Version, scala33Version) + trait CuttingEdge extends CrossScalaModule { + def moduleDeps = Seq(stable()) + } + } object HelloWorldDefaultMain extends HelloBase { object core extends HelloWorldModule @@ -666,6 +677,14 @@ object HelloWorldTests extends TestSuite { } } + "scala-33-depend-on-scala-32-works" - { + CrossModuleDeps.cuttingEdge(scala33Version).moduleDeps + } + "scala-213-depend-on-scala-212-fails" - { + val message = intercept[Exception](CrossModuleDeps.cuttingEdge(scala213Version).moduleDeps).getMessage + assert(message == "") + } + "runMain" - { "runMainObject" - workspaceTest(HelloWorld) { eval => val runResult = eval.outPath / "core" / "runMain.dest" / "hello-mill"