Skip to content

Commit

Permalink
Close #521 - Add support for Scala Native
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-lee committed Jan 10, 2024
1 parent 0029533 commit d1ee51a
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
scala:
- { name: "Scala 2", version: "2.12.13", binary-version: "2.12", java-version: "11", java-distribution: "temurin", report: "" }
- { name: "Scala 2", version: "2.13.6", binary-version: "2.13", java-version: "11", java-distribution: "temurin", report: "report" }
- { name: "Scala 3", version: "3.0.2", binary-version: "3", java-version: "11", java-distribution: "temurin", report: "" }
- { name: "Scala 3", version: "3.1.3", binary-version: "3", java-version: "11", java-distribution: "temurin", report: "" }

steps:
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
scala:
- { name: "Scala 2", version: "2.12.13", binary-version: "2.12", java-version: "11", java-distribution: "temurin", report: "" }
- { name: "Scala 2", version: "2.13.6", binary-version: "2.13", java-version: "11", java-distribution: "temurin", report: "" }
# - { name: "Scala 3", version: "3.0.2", binary-version: "3", java-version: "11", java-distribution: "temurin", report: "" }
# - { name: "Scala 3", version: "3.1.3", binary-version: "3", java-version: "11", java-distribution: "temurin", report: "" }

steps:
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
scala:
- { name: "Scala 2", version: "2.12.13", binary-version: "2.12", java-version: "11", java-distribution: "temurin", report: "" }
- { name: "Scala 2", version: "2.13.6", binary-version: "2.13", java-version: "11", java-distribution: "temurin", report: "report" }
- { name: "Scala 3", version: "3.0.2", binary-version: "3", java-version: "11", java-distribution: "temurin", report: "" }
- { name: "Scala 3", version: "3.1.3", binary-version: "3", java-version: "11", java-distribution: "temurin", report: "" }

steps:
- uses: actions/[email protected]
Expand Down
104 changes: 63 additions & 41 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,37 @@ lazy val effectie = (project in file("."))
.aggregate(
testing4CatsJvm,
testing4CatsJs,
testing4CatsNative,
coreJvm,
coreJs,
coreNative,
syntaxJvm,
syntaxJs,
syntaxNative,
timeJvm,
timeJs,
timeNative,
catsJvm,
catsJs,
catsNative,
catsEffect2Jvm,
catsEffect2Js,
catsEffect2Native,
catsEffect2TimeJvm,
catsEffect2TimeJs,
catsEffect2TimeNative,
catsEffect3Jvm,
catsEffect3Js,
catsEffect3Native,
catsEffect3TimeJvm,
catsEffect3TimeJs,
catsEffect3TimeNative,
monix3Jvm,
monix3Js,
monix3Native,
)

lazy val core = module(ProjectName("core"), crossProject(JVMPlatform, JSPlatform))
lazy val core = module(ProjectName("core"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Core",
libraryDependencies ++= List(
Expand All @@ -93,13 +103,14 @@ lazy val core = module(ProjectName("core"), crossProject(JVMPlatform, JSPlatform
)
.dependsOn(testing4Cats % Test)

lazy val coreJvm = core.jvm
lazy val coreJs = core
lazy val coreJvm = core.jvm
lazy val coreJs = core
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val coreNative = core.native.settings(nativeSettings)

lazy val syntax = module(ProjectName("syntax"), crossProject(JVMPlatform, JSPlatform))
lazy val syntax = module(ProjectName("syntax"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Syntax",
libraryDependencies ++= List(
Expand All @@ -111,12 +122,13 @@ lazy val syntax = module(ProjectName("syntax"), crossProject(JVMPlatform, JSP
libraryDependenciesPostProcess(isScala3(scalaVersion.value), libraryDependencies.value),
)
.dependsOn(core % props.IncludeTest)
lazy val syntaxJvm = syntax.jvm
lazy val syntaxJs = syntax
lazy val syntaxJvm = syntax.jvm
lazy val syntaxJs = syntax
.js
.settings(jsSettings)
lazy val syntaxNative = syntax.native.settings(nativeSettings)

lazy val cats = module(ProjectName("cats"), crossProject(JVMPlatform, JSPlatform))
lazy val cats = module(ProjectName("cats"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Cats",
libraryDependencies ++= List(
Expand All @@ -133,13 +145,14 @@ lazy val cats = module(ProjectName("cats"), crossProject(JVMPlatform, JSPlatform
testing4Cats % Test,
)

lazy val catsJvm = cats.jvm
lazy val catsJs = cats
lazy val catsJvm = cats.jvm
lazy val catsJs = cats
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val catsNative = cats.native.settings(nativeSettings)

lazy val testing4Cats = module(ProjectName("test4cats"), crossProject(JVMPlatform, JSPlatform))
lazy val testing4Cats = module(ProjectName("test4cats"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect's test utils for Cats",
libraryDependencies :=
Expand All @@ -150,12 +163,13 @@ lazy val testing4Cats = module(ProjectName("test4cats"), crossProject(JVMPlat
console / initialCommands :=
"""import effectie.testing.cats._""",
)
lazy val testing4CatsJvm = testing4Cats.jvm
lazy val testing4CatsJs = testing4Cats
lazy val testing4CatsJvm = testing4Cats.jvm
lazy val testing4CatsJs = testing4Cats
.js
.settings(jsSettings)
lazy val testing4CatsNative = testing4Cats.native.settings(nativeSettings)

lazy val time = module(ProjectName("time"), crossProject(JVMPlatform, JSPlatform))
lazy val time = module(ProjectName("time"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Time",
libraryDependencies ++= List(
Expand All @@ -178,13 +192,14 @@ lazy val time = module(ProjectName("time"), crossProject(JVMPlatform, JSPlatform
testing4Cats % Test,
)

lazy val timeJvm = time.jvm
lazy val timeJs = time
lazy val timeJvm = time.jvm
lazy val timeJs = time
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val timeNative = time.native.settings(nativeSettings)

lazy val catsEffect2 = module(ProjectName("cats-effect2"), crossProject(JVMPlatform, JSPlatform))
lazy val catsEffect2 = module(ProjectName("cats-effect2"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Cats Effect 2",
libraryDependencies :=
Expand Down Expand Up @@ -216,26 +231,27 @@ lazy val catsEffect2 = module(ProjectName("cats-effect2"), crossProject(JVMPl
cats % props.IncludeTest,
testing4Cats % Test,
)
lazy val catsEffect2Jvm = catsEffect2.jvm
lazy val catsEffect2Js = catsEffect2
lazy val catsEffect2Jvm = catsEffect2.jvm
lazy val catsEffect2Js = catsEffect2
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val catsEffect2Native = catsEffect2.native.settings(nativeSettings)

lazy val catsEffect2Time = module(ProjectName("cats-effect2-time"), crossProject(JVMPlatform, JSPlatform))
lazy val catsEffect2Time = module(ProjectName("cats-effect2-time"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Time with Cats Effect 2",
libraryDependencies :=
(SemVer.parseUnsafe(scalaVersion.value) match {
case SemVer(Major(2), Minor(11), _, _, _) =>
libraryDependencies.value ++ Seq(libs.libCatsCore_2_0_0, libs.libCatsEffect_2_0_0)
case SemVer(
Major(3),
Minor(0),
Patch(0),
Some(PreRelease(List(Dsv(List(Anh.Alphabet("RC"), Anh.Num("1")))))),
_,
) =>
Major(3),
Minor(0),
Patch(0),
Some(PreRelease(List(Dsv(List(Anh.Alphabet("RC"), Anh.Num("1")))))),
_,
) =>
libraryDependencies.value ++ Seq(
libs.libCatsCore(props.catsVersion),
libs.libCatsEffect(props.catsEffect2Version),
Expand All @@ -253,14 +269,14 @@ lazy val catsEffect2Time = module(ProjectName("cats-effect2-time"), crossProject
syntax % props.IncludeTest,
time,
)
lazy val catsEffect2TimeJvm = catsEffect2Time.jvm
lazy val catsEffect2TimeJs = catsEffect2Time
lazy val catsEffect2TimeJvm = catsEffect2Time.jvm
lazy val catsEffect2TimeJs = catsEffect2Time
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val catsEffect2TimeNative = catsEffect2Time.native.settings(nativeSettings)


lazy val catsEffect3 = module(ProjectName("cats-effect3"), crossProject(JVMPlatform, JSPlatform))
lazy val catsEffect3 = module(ProjectName("cats-effect3"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Cats Effect 3",
libraryDependencies ++= List(
Expand All @@ -279,13 +295,14 @@ lazy val catsEffect3 = module(ProjectName("cats-effect3"), crossProject(JVMPl
cats % props.IncludeTest,
testing4Cats % Test,
)
lazy val catsEffect3Jvm = catsEffect3.jvm
lazy val catsEffect3Js = catsEffect3
lazy val catsEffect3Jvm = catsEffect3.jvm
lazy val catsEffect3Js = catsEffect3
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val catsEffect3Native = catsEffect3.native.settings(nativeSettings)

lazy val catsEffect3Time = module(ProjectName("cats-effect3-time"), crossProject(JVMPlatform, JSPlatform))
lazy val catsEffect3Time = module(ProjectName("cats-effect3-time"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Time with Cats Effect 3",
libraryDependencies ++= List(
Expand All @@ -301,14 +318,14 @@ lazy val catsEffect3Time = module(ProjectName("cats-effect3-time"), crossProject
syntax % props.IncludeTest,
time,
)
lazy val catsEffect3TimeJvm = catsEffect3Time.jvm
lazy val catsEffect3TimeJs = catsEffect3Time
lazy val catsEffect3TimeJvm = catsEffect3Time.jvm
lazy val catsEffect3TimeJs = catsEffect3Time
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val catsEffect3TimeNative = catsEffect3Time.native.settings(nativeSettings)


lazy val monix3 = module(ProjectName("monix3"), crossProject(JVMPlatform, JSPlatform))
lazy val monix3 = module(ProjectName("monix3"), crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
description := "Effect Utils - Monix 3",
libraryDependencies :=
Expand All @@ -330,11 +347,12 @@ lazy val monix3 = module(ProjectName("monix3"), crossProject(JVMPlatform, JSP
catsEffect2 % props.IncludeTest,
testing4Cats % Test,
)
lazy val monix3Jvm = monix3.jvm
lazy val monix3Js = monix3
lazy val monix3Jvm = monix3.jvm
lazy val monix3Js = monix3
.js
.settings(jsSettingsForFuture)
.settings(jsSettings)
lazy val monix3Native = monix3.native.settings(nativeSettings)

lazy val docs = (project in file("docs-gen-tmp/docs"))
.enablePlugins(MdocPlugin, DocusaurPlugin)
Expand Down Expand Up @@ -429,11 +447,11 @@ lazy val props =
)
final val Scala2Version = Scala2Versions.head

final val Scala3Version = "3.0.2"
final val Scala3Version = "3.1.3"

// final val ProjectScalaVersion = "2.12.13"
final val ProjectScalaVersion = Scala2Version
// final val ProjectScalaVersion = Scala3Version
// final val ProjectScalaVersion = Scala2Version
final val ProjectScalaVersion = Scala3Version

lazy val licenses = List("MIT" -> url("http://opensource.org/licenses/MIT"))

Expand Down Expand Up @@ -642,3 +660,7 @@ lazy val jsSettingsForFuture: SettingsDefinition = List(
lazy val jsSettings: SettingsDefinition = List(
Test / fork := false
)

lazy val nativeSettings: SettingsDefinition = List(
Test / fork := false
)
5 changes: 5 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ addSbtPlugin("io.kevinlee" % "sbt-docusaur" % "0.15.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.11")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")

addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.2")

val sbtDevOopsVersion = "3.0.0"
addSbtPlugin("io.kevinlee" % "sbt-devoops-scala" % sbtDevOopsVersion)
addSbtPlugin("io.kevinlee" % "sbt-devoops-sbt-extra" % sbtDevOopsVersion)
Expand Down

0 comments on commit d1ee51a

Please sign in to comment.