diff --git a/scalalib/src/mill/scalalib/CrossModuleBase.scala b/scalalib/src/mill/scalalib/CrossModuleBase.scala index d8d9c81ffe3..87a54d5cb26 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 873536a6bd5..7bceebea13c 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 @@ -677,6 +688,16 @@ 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 == "Unable to find compatible cross version between 2.13.8 and 2.12.6,3.2.0") + } + "runMain" - { "runMainObject" - workspaceTest(HelloWorld) { eval => val runResult = eval.outPath / "core" / "runMain.dest" / "hello-mill"