{"id":40292989,"url":"https://github.com/portable-scala/sbt-crossproject","last_synced_at":"2026-01-20T05:02:32.450Z","repository":{"id":43013530,"uuid":"59822325","full_name":"portable-scala/sbt-crossproject","owner":"portable-scala","description":"Cross-platform compilation support for sbt.","archived":false,"fork":false,"pushed_at":"2024-10-23T03:24:13.000Z","size":182,"stargazers_count":241,"open_issues_count":8,"forks_count":31,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-07T23:53:00.885Z","etag":null,"topics":["sbt","sbt-cross","sbt-plugin","scala","scala-js","scala-native"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/portable-scala.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2016-05-27T09:22:04.000Z","updated_at":"2025-04-10T01:44:53.000Z","dependencies_parsed_at":"2024-08-28T11:12:01.017Z","dependency_job_id":null,"html_url":"https://github.com/portable-scala/sbt-crossproject","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/portable-scala/sbt-crossproject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/portable-scala%2Fsbt-crossproject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/portable-scala%2Fsbt-crossproject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/portable-scala%2Fsbt-crossproject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/portable-scala%2Fsbt-crossproject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/portable-scala","download_url":"https://codeload.github.com/portable-scala/sbt-crossproject/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/portable-scala%2Fsbt-crossproject/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28596087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["sbt","sbt-cross","sbt-plugin","scala","scala-js","scala-native"],"created_at":"2026-01-20T05:02:32.380Z","updated_at":"2026-01-20T05:02:32.442Z","avatar_url":"https://github.com/portable-scala.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003esbt-crossproject\u003c/h1\u003e\n\n\n[![Join the chat at https://gitter.im/scala-native/sbt-crossproject](https://badges.gitter.im/scala-native/sbt-crossproject.svg)](https://gitter.im/scala-native/sbt-crossproject)\n\n[![Build Status](https://github.com/portable-scala/sbt-crossproject/actions/workflows/ci.yml/badge.svg)](https://github.com/portable-scala/sbt-crossproject/actions)\n\nCross-platform compilation support for sbt.\n\nRequirements:\n\n* sbt 1.2.1+\n* For `JSPlatform`: Scala.js 0.6.23+ or 1.0.0+\n* For `NativePlatform`: Scala Native 0.3.7+\n\nIf you are still using sbt 0.13.x, you must use sbt-crossproject v0.6.1 instead of v1.3.2.\n\n\u003ch2\u003eInstallation\u003c/h2\u003e\n\n\u003ch3\u003eCross-Compiling Scala.js, JVM and Native\u003c/h3\u003e\n\nIn `project/plugins.sbt`:\n\n```scala\naddSbtPlugin(\"org.portable-scala\" % \"sbt-scalajs-crossproject\"      % \"1.3.2\")\naddSbtPlugin(\"org.portable-scala\" % \"sbt-scala-native-crossproject\" % \"1.3.2\")\naddSbtPlugin(\"org.scala-js\"       % \"sbt-scalajs\"                   % \"1.16.0\")\naddSbtPlugin(\"org.scala-native\"   % \"sbt-scala-native\"              % \"0.5.4\")\n```\n\nIn `build.sbt`:\n\n```scala\n// If you are using Scala.js 0.6.x, you need the following import:\n//import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}\n\nval sharedSettings = Seq(scalaVersion := \"2.13.14\")\n\nlazy val bar =\n  // select supported platforms\n  crossProject(JSPlatform, JVMPlatform, NativePlatform)\n    .crossType(CrossType.Pure) // [Pure, Full, Dummy], default: CrossType.Full\n    .settings(sharedSettings)\n    .jsSettings(/* ... */) // defined in sbt-scalajs-crossproject\n    .jvmSettings(/* ... */)\n    // configure Scala-Native settings\n    .nativeSettings(/* ... */) // defined in sbt-scala-native\n\n// Optional in sbt 1.x (mandatory in sbt 0.13.x)\nlazy val barJS     = bar.js\nlazy val barJVM    = bar.jvm\nlazy val barNative = bar.native\n\nlazy val foo =\n  crossProject(JSPlatform, JVMPlatform, NativePlatform)\n    .settings(sharedSettings)\n    .settings(\n      // %%% now include Scala Native. It applies to all selected platforms\n      libraryDependencies += \"org.example\" %%% \"foo\" % \"1.2.3\"\n    )\n\n// Optional in sbt 1.x (mandatory in sbt 0.13.x)\nlazy val fooJS = foo.js\nlazy val fooJVM = foo.jvm\nlazy val fooNative = foo.native\n```\n\n\u003ch3\u003eRemoving the platform suffix for one \"default\" platform\u003c/h3\u003e\n\nIf you mainly use one \"default\" platform in your everyday development, you can tell sbt-crossproject not to add the platform suffix to its project ID.\nFor example, assuming you mainly compile and test for the JVM, you can write:\n\n```scala\nlazy val bar =\n  crossProject(JSPlatform, JVMPlatform, NativePlatform)\n    .withoutSuffixFor(JVMPlatform)\n    .crossType(...)\n    .settings(...)\n\n// Optional in sbt 1.x (mandatory in sbt 0.13.x)\nlazy val barJS     = bar.js\nlazy val barJVM    = bar.jvm\nlazy val barNative = bar.native\n```\n\nThe call to `withoutSuffixFor` must come first after the call to `crossProject()`, otherwise it will not compile.\n\nNow, in the sbt prompt, you can do\n\n```\n\u003e bar/test\n```\n\nto test the JVM platform (instead of `barJVM/test`).\nThis of course applies to all tasks.\n\nNote that *inside the build*, you still need to use `barJVM` to the JVM `Project`.\n`withoutSuffixFor` only changes the `id` of the project, which is used in the sbt prompt.\n\n\u003ch3\u003eDetecting the current platform in a project's settings\u003c/h3\u003e\n\nWithin the settings of a `crossProject`, you can detect the platform for which those settings are being applied to with `crossProjectPlatform`.\nHere is a contrived example:\n\n```scala\nlazy val bar =\n  crossProject(JSPlatform, JVMPlatform, NativePlatform)\n    .crossType(...)\n    .settings(\n      name := \"bar for \" + crossProjectPlatform.value.identifier\n    )\n\n...\n```\n\n\u003ch3\u003eCross-Compiling JVM and Native\u003c/h3\u003e\n\nIn `project/plugins.sbt`:\n\n```scala\naddSbtPlugin(\"org.portable-scala\" % \"sbt-scala-native-crossproject\" % \"1.3.2\")\naddSbtPlugin(\"org.scala-native\"   % \"sbt-scala-native\"              % \"0.5.4\")\n```\n\nIn `build.sbt`:\n\n```scala\nval sharedSettings = Seq(scalaVersion := \"2.11.12\")\n\nlazy val bar =\n  // select supported platforms\n  crossProject(JVMPlatform, NativePlatform)\n    .settings(sharedSettings)\n    // configure JVM settings\n    .jvmSettings(/* ... */)\n    // configure Scala-Native settings\n    .nativeSettings(/* ... */) // defined in sbt-scala-native\n\n// Optional in sbt 1.x (mandatory in sbt 0.13.x)\nlazy val barJVM    = bar.jvm\nlazy val barNative = bar.native\n```\n\n\u003ch3\u003eMigration from Scala.js 0.6.x' default crossProject\u003c/h3\u003e\n\nWe carefully implemented sbt-crossproject to be mostly source compatible with Scala.js crossProject\n\nIn `project/plugins.sbt`:\n\n```scala\naddSbtPlugin(\"org.portable-scala\" % \"sbt-scalajs-crossproject\" % \"1.3.2\")\naddSbtPlugin(\"org.scala-js\"       % \"sbt-scalajs\"              % \"0.6.33\")\n```\n\nIn `build.sbt`:\n\n```scala\n// shadow sbt-scalajs' crossProject and CrossType from Scala.js 0.6.x\nimport sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}\n\nlazy val bar =\n  // select supported platforms\n  crossProject(JSPlatform, JVMPlatform)\n    .crossType(CrossType.Pure) // [Pure, Full, Dummy], default: CrossType.Full\n    .settings(/* ... */)\n    .jsSettings(/* ... */) // defined in sbt-scalajs-crossproject\n    .jvmSettings(/* ... */)\n\n// Optional in sbt 1.x (mandatory in sbt 0.13.x)\nlazy val barJS = bar.js\nlazy val barJVM = bar.jvm\n```\n\n\u003ch3\u003eWhen using Build.scala\u003c/h3\u003e\n\n```\nimport org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._\nimport sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType, _}\nimport scalajscrossproject.ScalaJSCrossPlugin.autoImport._\nimport scalanativecrossproject.ScalaNativeCrossPlugin.autoImport._\n```\n\n\u003ch2\u003eConfiguration\u003c/h2\u003e\n\n\u003ch3\u003eCrossTypes\u003c/h3\u003e\n\nSetting a specific CrossType allows the definition of a custom source tree\nlayout for managing native-, js- and jvm-specific sources in directories of their\nown.\n\nsbt-cross provides by default 3 implementations of the CrossType class that one can\npass as `.crossType` parameter:\n\n- `.crossType(CrossType.Pure)`:\n\n```\n.\n├── .js\n├── .jvm\n├── .native\n└── src\n```\nThis layout is preferred for codebases which do not contain any platform-specific code.\n\nSince this is the case of most existing sbt projects it is often desired during conversion to sbt-cross to place the cross-project at the root of the project source tree.\n\nThis can be done with the following set of options:\n\n`lazy val foo = crossProject.crossType(CrossType.Pure).in(file(\".\"))`\n\n- `.crossType(CrossType.Full)`\n\n```\n.\n├── js\n├── jvm\n├── native\n└── shared\n```\n\nThis layout gives full control by providing a `shared` directory for common code.\n\n- `.crossType(CrossType.Dummy)`\n\n```\n.\n├── js\n├── jvm\n└── native\n```\n\n- `.crossType({/*custom*/})`\n\nOne can easily extend CrossType and provide a custom tree structure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fportable-scala%2Fsbt-crossproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fportable-scala%2Fsbt-crossproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fportable-scala%2Fsbt-crossproject/lists"}