Skip to content

Commit

Permalink
Allow resolving moduleDeps with older Scala 3 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lolgab committed Nov 15, 2023
1 parent e93f6bd commit 38de173
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/CrossModuleBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
19 changes: 19 additions & 0 deletions scalalib/test/src/mill/scalalib/HelloWorldTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 == "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"
Expand Down

0 comments on commit 38de173

Please sign in to comment.