From e0ccb89e90054a66330931de16ea25d82d3f3463 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sun, 19 Mar 2023 23:59:22 +1100 Subject: [PATCH] Close #521 - Add support for Scala Native --- .github/workflows/build.yml | 2 +- .github/workflows/checks.yml | 2 +- .github/workflows/release.yml | 2 +- build.sbt | 62 ++++++++++++++++++++++------------- project/plugins.sbt | 5 +++ 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3a4d98b..1ab4f8c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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/checkout@v3.3.0 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 062273f1..a1ca0f56 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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/checkout@v3.3.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a90d78f..4bf60538 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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/checkout@v3.3.0 diff --git a/build.sbt b/build.sbt index ee232cb2..452e8c36 100644 --- a/build.sbt +++ b/build.sbt @@ -55,21 +55,28 @@ lazy val effectie = (project in file(".")) .aggregate( testing4CatsJvm, testing4CatsJs, + testing4CatsNative, coreJvm, coreJs, + coreNative, syntaxJvm, syntaxJs, + syntaxNative, catsJvm, catsJs, + catsNative, catsEffect2Jvm, catsEffect2Js, + catsEffect2Native, catsEffect3Jvm, catsEffect3Js, + catsEffect3Native, 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( @@ -87,13 +94,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( @@ -105,12 +113,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( @@ -127,13 +136,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 := @@ -144,12 +154,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 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 := @@ -181,13 +192,14 @@ 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 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( @@ -206,13 +218,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 monix3 = module(ProjectName("monix3"), crossProject(JVMPlatform, JSPlatform)) +lazy val monix3 = module(ProjectName("monix3"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Effect Utils - Monix 3", libraryDependencies := @@ -234,11 +247,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) @@ -333,7 +347,7 @@ 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 @@ -546,3 +560,7 @@ lazy val jsSettingsForFuture: SettingsDefinition = List( lazy val jsSettings: SettingsDefinition = List( Test / fork := false ) + +lazy val nativeSettings: SettingsDefinition = List( + Test / fork := false +) diff --git a/project/plugins.sbt b/project/plugins.sbt index d18ec386..ea5a0ea0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -13,6 +13,11 @@ addSbtPlugin("io.kevinlee" % "sbt-docusaur" % "0.13.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 = "2.24.0" addSbtPlugin("io.kevinlee" % "sbt-devoops-scala" % sbtDevOopsVersion) addSbtPlugin("io.kevinlee" % "sbt-devoops-sbt-extra" % sbtDevOopsVersion)