Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow resolving moduleDeps with older Scala 3 versions #2877

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 21 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 @@ -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"
Expand Down