Replies: 6 comments 6 replies
-
At this point, the problematic parts I see are:
trait FooModule extends ... {
object jvm extends JVMModule
object js extends JSModule
object native extends NativeModule
} Perhaps this is already possible and I just didn't find the right way to implement the pattern yet. Edit: this seems to work, actually... trait SharedJVM extends Shared {
object test extends ScalaTests with SharedTestModule
}
trait SharedJS extends Shared with ScalaJSModule {
def scalaJSVersion = "1.16.0"
object test extends ScalaJSTests with SharedTestModule
}
val scalaVersions = Seq("2.13.14", "3.3.6")
object bar extends Module {
// 2 lines per axis, sounds doable
object jvm extends Cross[JvmModule](scalaVersions)
trait JvmModule extends SharedJVM
object js extends Cross[JsModule](scalaVersions)
trait JsModule extends SharedJS
}
|
Beta Was this translation helpful? Give feedback.
-
Another thing which @ghostbuster91 reminded me about: the package build
import mill._
val crossMatrix = for {
crossVersion <- Seq("2.10", "2.11", "2.12")
platform <- Seq("jvm", "js", "native")
if !(platform == "native" && crossVersion != "2.12")
} yield (crossVersion, platform)
object foo extends mill.Cross[FooModule](crossMatrix)
trait FooModule extends Cross.Module2[String, String] {
val (crossVersion, platform) = (crossValue, crossValue2)
def suffix = Task { "_" + crossVersion + "_" + platform }
}
def bar = Task { s"hello ${foo("2.10", "jvm").suffix()}" } The example itself doesn't elaborate any further, and I'm not even sure it's actually possible to combine this example with |
Beta Was this translation helpful? Give feedback.
-
👍 The current approach is not only verbose but also potentially error-prone, as cross-module dependency declarations can easily become inconsistent across platforms. In most cases, this will surface as a compile-time error, but in scenarios involving dynamic class loading, it may lead to subtle runtime failures. While it's possible to mitigate this by introducing additional abstraction layers to express dependencies in a platform-agnostic way, doing so adds complexity. Moreover, given the fast-paced evolution of the Mill project, maintaining such abstractions across version upgrades can become particularly challenging. |
Beta Was this translation helpful? Give feedback.
-
Cross modules are a poor fit for this use case, because cross modules are by definition homogenously typed and dynamically enumerated, while cross platform modules are typically heterogenouslyntyped and statically enumerated. I think the solution to get a more SBT-esque ease of use would be to define a Can definitely be done, would take some legwork but I don't see any blockers |
Beta Was this translation helpful? Give feedback.
-
I wrote a plugin to simplify cross-platform support. It was before Mill adopted its own |
Beta Was this translation helpful? Give feedback.
-
It would help in many situations, when |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
(moved from Discord)
I saw the docs, and so far the most comprehensive example for cross-building with platform axes is https://mill-build.org/mill/scalalib/web-examples.html#_publishing_cross_platform_scala_modules and https://mill-build.org/mill/scalalib/web-examples.html#_publishing_cross_platform_scala_modules_alternative.
and it appears to be a little bit too verbose... like, for each module you need to duplicate this amount of code inside
and that's just 2 platforms - most OSS projects now have 3.
If this isn't a lot, let's add cross-module dependencies:
is it me or is this not going to scale? Having to configure each variant individually seems way more troublesome than "just" using sbt-projectmatrix and having entire rows configured with a single line.
Is this something you'd be interested in revisiting in future Mill versions?
Beta Was this translation helpful? Give feedback.
All reactions