Skip to content

Commit

Permalink
Multiplatform (#240)
Browse files Browse the repository at this point in the history
* Multiplatform

* Fix JVM

* Remove Scala 3 JS tests

* bad option: '-scalajs'
  • Loading branch information
sideeffffect authored Mar 8, 2023
1 parent b9711be commit 2b8dbac
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ jobs:
- ++2.12.17 zioOpticsJVM
- ++2.13.10 zioOpticsJVM
- ++3.2.2 zioOpticsJVM
- ++2.11.12 zioOpticsNative
- ++2.12.17 zioOpticsNative
- ++2.13.10 zioOpticsNative
- ++3.2.2 zioOpticsNative
- ++2.11.12 zioOpticsJS
- ++2.12.17 zioOpticsJS
- ++2.13.10 zioOpticsJS
steps:
Expand Down
3 changes: 3 additions & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-J-Xmx6G
-J-Xss4M
-J-XX:+UseG1GC
48 changes: 24 additions & 24 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ inThisBuild(
),
supportedScalaVersions :=
Map(
(zioOpticsJVM / thisProject).value.id -> (zioOpticsJVM / crossScalaVersions).value,
(zioOpticsNative / thisProject).value.id -> (zioOpticsNative / crossScalaVersions).value,
(zioOpticsJS / thisProject).value.id -> (zioOpticsJS / crossScalaVersions).value
(zioOptics.jvm / thisProject).value.id -> (zioOptics.jvm / crossScalaVersions).value,
(zioOptics.native / thisProject).value.id -> (zioOptics.native / crossScalaVersions).value,
(zioOptics.js / thisProject).value.id -> (zioOptics.js / crossScalaVersions).value.filterNot(_ == scala3.value)
)
)
)
Expand All @@ -46,7 +46,7 @@ addCommandAlias(
";zioOpticsNative/test:compile"
)

val zioVersion = "2.0.6"
val zioVersion = "2.0.10"

lazy val root = project
.in(file("."))
Expand All @@ -55,33 +55,33 @@ lazy val root = project
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library")
)
.aggregate(
zioOpticsJVM,
zioOpticsJS,
zioOpticsNative,
zioOptics.jvm,
zioOptics.js,
zioOptics.native,
docs
)

lazy val zioOptics = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("zio-optics"))
.settings(stdSettings(name = "zio-optics", packageName = Some("zio.optics"), enableCrossProject = true))
.settings(enableZIO())

lazy val zioOpticsJS = zioOptics.js
.settings(jsSettings)
.settings(
crossScalaVersions --= Seq(scala211.value, scala3.value),
libraryDependencies += "dev.zio" %%% "zio-test-sbt" % zioVersion % Test
)
.settings(scalaJSUseMainModuleInitializer := true)

lazy val zioOpticsJVM = zioOptics.jvm
.settings(scala3Settings)
.settings(libraryDependencies += "dev.zio" %%% "zio-test-sbt" % zioVersion % Test)
.settings(scalaReflectTestSettings)

lazy val zioOpticsNative = zioOptics.native
.settings(nativeSettings)
.settings(crossScalaVersions -= scala211.value)
.jvmSettings(scala3Settings)
.jvmSettings(scalaReflectTestSettings)
.jsSettings(jsSettings)
.jsSettings(
scalaJSUseMainModuleInitializer := true,
scalacOptions ++= {
if (scalaVersion.value == scala3.value) List("-scalajs") else List() // https://github.com/zio/zio-sbt/pull/150
},
excludeDependencies += ExclusionRule("org.portable-scala", "portable-scala-reflect_2.13")
)
.nativeSettings(nativeSettings)
.nativeSettings(
excludeDependencies += ExclusionRule("org.portable-scala", "portable-scala-reflect_2.13")
)

lazy val docs = project
.in(file("zio-optics-docs"))
Expand All @@ -91,9 +91,9 @@ lazy val docs = project
scalacOptions -= "-Xfatal-warnings",
crossScalaVersions -= scala211.value,
projectName := (ThisBuild / name).value,
mainModuleName := (zioOpticsJVM / moduleName).value,
mainModuleName := (zioOptics.jvm / moduleName).value,
projectStage := ProjectStage.Development,
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(zioOpticsJVM)
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(zioOptics.jvm)
)
.dependsOn(zioOpticsJVM)
.dependsOn(zioOptics.jvm)
.enablePlugins(WebsitePlugin)
28 changes: 24 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
val zioSbtVersion = "0.3.10+43-080b598b-SNAPSHOT"

addSbtPlugin("dev.zio" % "zio-sbt-ecosystem" % zioSbtVersion)
addSbtPlugin("dev.zio" % "zio-sbt-website" % zioSbtVersion)
addSbtPlugin("dev.zio" % "zio-sbt-ci" % zioSbtVersion)
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1")
addSbtPlugin(
"dev.zio" % "zio-sbt-ecosystem" % zioSbtVersion exclude ("org.scala-js", "sbt-scalajs") exclude ("org.scala-native", "sbt-scala-native")
)
addSbtPlugin(
"dev.zio" % "zio-sbt-website" % zioSbtVersion exclude ("org.scala-js", "sbt-scalajs") exclude ("org.scala-native", "sbt-scala-native")
)
addSbtPlugin(
"dev.zio" % "zio-sbt-ci" % zioSbtVersion exclude ("org.scala-js", "sbt-scalajs") exclude ("org.scala-native", "sbt-scala-native")
)
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.12.0") // Still supports 2.11
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.9") // Still supports 2.11

resolvers ++= Resolver.sonatypeOssRepos("public")

import sbt.internal.librarymanagement.mavenint.PomExtraDependencyAttributes

ThisBuild / dependencyOverrides ++= List(
"org.scala-js" % "sbt-scalajs" % "1.12.0",
"org.scala-native" % "sbt-scala-native" % "0.4.9"
).map(
_.extra(
PomExtraDependencyAttributes.SbtVersionKey -> (update / scalaBinaryVersion).value,
PomExtraDependencyAttributes.ScalaVersionKey -> sbtVersion.value
)
)

0 comments on commit 2b8dbac

Please sign in to comment.