{"id":17280689,"url":"https://github.com/lolgab/mill-crossplatform","last_synced_at":"2025-08-19T08:42:25.945Z","repository":{"id":65507753,"uuid":"556399677","full_name":"lolgab/mill-crossplatform","owner":"lolgab","description":"Mill Plugin to ease Cross Platform projects","archived":false,"fork":false,"pushed_at":"2023-11-08T13:40:43.000Z","size":57,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T23:02:50.210Z","etag":null,"topics":["mill-plugin"],"latest_commit_sha":null,"homepage":"https://lolgab.github.io/mill-crossplatform/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lolgab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-23T19:08:00.000Z","updated_at":"2025-01-08T01:54:14.000Z","dependencies_parsed_at":"2023-11-08T14:38:12.880Z","dependency_job_id":null,"html_url":"https://github.com/lolgab/mill-crossplatform","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolgab%2Fmill-crossplatform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolgab%2Fmill-crossplatform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolgab%2Fmill-crossplatform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolgab%2Fmill-crossplatform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lolgab","download_url":"https://codeload.github.com/lolgab/mill-crossplatform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248856004,"owners_count":21172678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mill-plugin"],"created_at":"2024-10-15T09:21:30.050Z","updated_at":"2025-08-19T08:42:25.928Z","avatar_url":"https://github.com/lolgab.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CrossPlatform Mill Plugin\n\nMill Plugin to simplify Cross platform Mill projects\n\n## Getting Started\n\nHere you can see a basic example using mill-crossplatform\n\n```scala\n//| mill-version: 1.0.0\n//| mvnDeps:\n//| - com.github.lolgab::mill-crossplatform::0.3.0\n\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport com.github.lolgab.mill.crossplatform._\n\ntrait Common extends ScalaModule {\n  def scalaVersion = \"3.7.0\"\n}\n\ntrait CommonNative extends ScalaNativeModule {\n  def scalaNativeVersion = \"0.5.7\"\n}\ntrait CommonJS extends ScalaJSModule {\n  def scalaJSVersion = \"1.19.0\"\n}\n\nobject core extends CrossPlatform {\n  trait Shared extends CrossPlatformScalaModule with Common {\n    // common `core` settings here\n  }\n  object jvm extends Shared {\n    // jvm specific settings here\n  }\n  object js extends Shared with CommonJS {\n    // js specific settings here\n  }\n  object native extends Shared with CommonNative {\n    // native specific settings here\n  }\n}\n\nobject other extends CrossPlatform {\n  // root moduleDeps are correctly applied\n  // to all platform submodules\n  def moduleDeps = Seq(core)\n  trait Shared extends CrossPlatformScalaModule with Common {\n    // common `other` settings here\n  }\n  object jvm extends Shared\n  object js extends Shared with CommonJS\n  object native extends Shared with CommonNative\n}\n```\n\n## Advanced use cases\n\n## Platform specific code\n\nYou can place platform specific code in:\n\n```scala\n// jvm specific code\nmillSourcePath / \"jvm\" / \"src\"\n\n// directory used in js and jvm modules but not in native\n// the directory names are sorted alphabetically.\n// it's `js-jvm`, not `jvm-js`.\nmillSourcePath / \"js-jvm\" / \"src\"\n\n// code shared between js and native\n// used when the scalaVersion is a Scala 3\n// version\nmillSourcePath / \"js-native\" / \"src-3\"\n```\n\n\n### Supporting multiple Scala versions\n\nIt is possible to use `CrossPlatform` together with `Cross`\nto cross-compile for multiple Scala versions.\n\n#### With Mill 0.11\n\n```scala\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport $ivy.`com.github.lolgab::mill-crossplatform::0.2.4`\nimport com.github.lolgab.mill.crossplatform._\n\ntrait CommonNative extends ScalaNativeModule {\n  def scalaNativeVersion = \"0.4.15\"\n}\ntrait CommonJS extends ScalaJSModule {\n  def scalaJSVersion = \"1.14.0\"\n}\n\nval scalaVersions = Seq(\"2.13.12\", \"3.3.1\")\n\nobject core extends Cross[CoreModule](scalaVersions)\ntrait CoreModule extends CrossPlatform {\n  // Note `CrossPlatformCrossScalaModule` instead of `CrossPlatformScalaModule`\n  trait Shared extends CrossPlatformCrossScalaModule\n  object jvm extends Shared\n  object js extends Shared with CommonJS\n  object native extends Shared with CommonNative\n}\n\nobject app extends Cross[AppModule](scalaVersions)\ntrait AppModule extends CrossPlatform {\n  def moduleDeps = Seq(core())\n  trait Shared extends CrossPlatformCrossScalaModule\n  object jvm extends Shared\n  object js extends Shared with CommonJS\n  object native extends Shared with CommonNative\n}\n```\n\n#### With Mill 0.10\n\n```scala\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport $ivy.`com.github.lolgab::mill-crossplatform::0.2.2`\nimport com.github.lolgab.mill.crossplatform._\n\ntrait CommonNative extends ScalaNativeModule {\n  def scalaNativeVersion = \"0.4.15\"\n}\ntrait CommonJS extends ScalaJSModule {\n  def scalaJSVersion = \"1.14.0\"\n}\n\nval scalaVersions = Seq(\"2.13.12\", \"3.3.1\")\n\nobject core extends Cross[CoreModule](scalaVersions: _*)\nclass CoreModule(val crossScalaVersion: String) extends CrossPlatform {\n  // Note `CrossPlatformCrossScalaModule` instead of `CrossPlatformScalaModule`\n  trait Shared extends CrossPlatformCrossScalaModule\n  object jvm extends Shared\n  object js extends Shared with CommonJS\n  object native extends Shared with CommonNative\n}\n\nobject app extends Cross[AppModule](scalaVersions: _*)\nclass AppModule(val crossScalaVersion: String) extends CrossPlatform {\n  def moduleDeps = Seq(core())\n  trait Shared extends CrossPlatformCrossScalaModule\n  object jvm extends Shared\n  object js extends Shared with CommonJS\n  object native extends Shared with CommonNative\n}\n```\n\n### Supporting multiple Scala.js / Native versions\n\nIt is possible to use `CrossPlatform` together with `Cross`\nin the inner modules to cross-compile for multiple Scala.js / Scala Native versions.\nRoot `moduleDeps` and `compileModuleDeps` work as expected\n\n#### With Mill 0.11\n\n```scala\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport $ivy.`com.github.lolgab::mill-crossplatform::0.2.4`\nimport com.github.lolgab.mill.crossplatform._\n\nval scalaVersions = Seq(\"2.13.12\", \"3.3.1\")\nval scalaJSVersions = Seq(\"1.14.0\")\n\nobject core extends Cross[CoreModule](scalaVersions)\ntrait CoreModule extends CrossPlatform {\n  trait Shared extends CrossPlatformCrossScalaModule\n  object jvm extends Shared\n  object js extends Cross[JSModule](scalaJSVersions)\n  trait JSModule extends Shared with CrossScalaJSModule\n}\n```\n\n#### With Mill 0.10\n\n```scala\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport $ivy.`com.github.lolgab::mill-crossplatform::0.2.2`\nimport com.github.lolgab.mill.crossplatform._\n\nval scalaVersions = Seq(\"2.13.12\", \"3.3.1\")\nval scalaJSVersions = Seq(\"1.14.0\")\n\nobject core extends Cross[CoreModule](scalaVersions: _*)\nclass CoreModule(val crossScalaVersion: String) extends CrossPlatform {\n  trait Shared extends CrossPlatformCrossScalaModule\n  object jvm extends Shared\n  // the cross-module should have only one parameter named `val crossScalaJSVersion: String`\n  // for it to work correctly. Extend `CrossScalaJSModule` which requires it.\n  object js extends Cross[JSModule](scalaJSVersions: _*)\n  class JSModule(val crossScalaJSVersion: String) extends Shared with CrossScalaJSModule\n}\n```\n\n### Disabling platforms dynamically\n\nIt is possible to disable a platform dynamically.\nThis is useful, for example, when a platform doesn't support a certain Scala version.\n\n#### With Mill 0.11\n\n```scala\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport $ivy.`com.github.lolgab::mill-crossplatform::0.2.4`\nimport com.github.lolgab.mill.crossplatform._\n\nval scalaVersions = Seq(\"2.13.12\", \"3.3.1\")\n\nobject core extends Cross[CoreModule](scalaVersions)\ntrait CoreModule extends CrossPlatform {\n  trait Shared extends CrossPlatformCrossScalaModule\n  \n  // Enable Scala Native only for Scala 2\n  def enableNative = crossValue.startsWith(\"2.\")\n\n  object jvm extends Shared\n  object js extends Shared with ScalaJSModule {\n    def scalaJSVersion = \"1.14.0\"\n  }\n  object native extends Shared with ScalaNativeModule {\n    def scalaNativeVersion = \"0.4.12\"\n  }\n}\n```\n\n#### With Mill 0.10\n\n```scala\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport $ivy.`com.github.lolgab::mill-crossplatform::0.2.2`\nimport com.github.lolgab.mill.crossplatform._\n\nval scalaVersions = Seq(\"2.13.12\", \"3.3.1\")\n\nobject core extends Cross[CoreModule](scalaVersions: _*)\nclass CoreModule(crossScalaVersion: String) extends CrossPlatform {\n  trait Shared extends CrossPlatformCrossScalaModule\n  \n  // Enable Scala Native only for Scala 2\n  def enableNative = crossScalaVersion.startsWith(\"2.\")\n\n  object jvm extends Shared\n  object js extends Shared with ScalaJSModule {\n    def scalaJSVersion = \"1.14.0\"\n  }\n  object native extends Shared with ScalaNativeModule {\n    def scalaNativeVersion = \"0.4.12\"\n  }\n}\n```\n\n### Test modules\n\nFor tests, you need to have platform specific test modules\n\n#### With Mill 0.11\n\n```scala\nimport mill._, mill.scalalib._, mill.scalajslib._, mill.scalanativelib._\nimport $ivy.`com.github.lolgab::mill-crossplatform::0.2.4`\nimport com.github.lolgab.mill.crossplatform._\n\ntrait Common extends ScalaModule {\n  def scalaVersion = \"3.3.1\"\n}\ntrait CommonNative extends ScalaNativeModule {\n  def scalaNativeVersion = \"0.4.15\"\n}\ntrait CommonJS extends ScalaJSModule {\n  def scalaJSVersion = \"1.14.0\"\n}\ntrait CommonTests extends TestModule.Munit {\n  def ivyDeps = super.ivyDeps() ++ Agg(\n    ivy\"org.scalameta::munit::1.0.0-M10\"\n  )\n}\n\nobject core extends CrossPlatform {\n  trait Shared extends CrossPlatformScalaModule with Common {\n    // common `core` settings here\n    trait SharedTests extends CommonTests {\n      // common `core` test settings here\n    }\n  }\n  object jvm extends Shared {\n    // jvm specific settings here\n    object test extends ScalaTests with SharedTests\n  }\n  object js extends Shared with CommonJS {\n    // js specific settings here\n    object test extends ScalaJSTests with SharedTests\n  }\n  object native extends Shared with CommonNative {\n    // native specific settings here\n    object test extends ScalaNativeTests with SharedTests\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flolgab%2Fmill-crossplatform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flolgab%2Fmill-crossplatform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flolgab%2Fmill-crossplatform/lists"}