From 293ccc85b47232ff125ea6e18e051395964d4545 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Wed, 22 Mar 2023 23:14:10 +1100 Subject: [PATCH] Close #433 - Add support for Scala Native --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- build.sbt | 150 ++++++++++++++++++++-------------- project/plugins.sbt | 5 ++ 4 files changed, 96 insertions(+), 63 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca476e80..b8b2a6d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62778382..c358153d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,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 diff --git a/build.sbt b/build.sbt index 620715d2..907db232 100644 --- a/build.sbt +++ b/build.sbt @@ -69,28 +69,38 @@ lazy val loggerF = (project in file(".")) .aggregate( coreJvm, coreJs, + coreNative, slf4jLoggerJvm, slf4jLoggerJs, + slf4jLoggerNative, log4sLoggerJvm, log4sLoggerJs, + log4sLoggerNative, log4jLoggerJvm, log4jLoggerJs, + log4jLoggerNative, sbtLoggingJvm, sbtLoggingJs, + sbtLoggingNative, catsJvm, catsJs, + catsNative, testKitJvm, testKitJs, + testKitNative, catsEffectJvm, catsEffectJs, + catsEffectNative, catsEffect3Jvm, catsEffect3Js, + catsEffect3Native, monixJvm, monixJs, + monixNative, ) -lazy val core = - module(ProjectName("core"), crossProject(JVMPlatform, JSPlatform)) +lazy val core = + module(ProjectName("core"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Core", libraryDependencies ++= List( @@ -104,10 +114,11 @@ lazy val core = libraryDependencies.value, ), ) -lazy val coreJvm = core.jvm -lazy val coreJs = core.js +lazy val coreJvm = core.jvm +lazy val coreJs = core.js +lazy val coreNative = core.native.settings(nativeSettings) -lazy val slf4jLogger = module(ProjectName("slf4j"), crossProject(JVMPlatform, JSPlatform)) +lazy val slf4jLogger = module(ProjectName("slf4j"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Logger with Slf4j", libraryDependencies ++= Seq( @@ -119,11 +130,12 @@ lazy val slf4jLogger = module(ProjectName("slf4j"), crossProject(JVMPlatform, ), ) .dependsOn(core) -lazy val slf4jLoggerJvm = slf4jLogger.jvm -lazy val slf4jLoggerJs = slf4jLogger.js +lazy val slf4jLoggerJvm = slf4jLogger.jvm +lazy val slf4jLoggerJs = slf4jLogger.js +lazy val slf4jLoggerNative = slf4jLogger.native.settings(nativeSettings) -lazy val log4sLogger = - module(ProjectName("log4s"), crossProject(JVMPlatform, JSPlatform)) +lazy val log4sLogger = + module(ProjectName("log4s"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Logger with Log4s", libraryDependencies := libraryDependenciesRemoveScala3Incompatible( @@ -135,11 +147,12 @@ lazy val log4sLogger = ), ) .dependsOn(core) -lazy val log4sLoggerJvm = log4sLogger.jvm -lazy val log4sLoggerJs = log4sLogger.js +lazy val log4sLoggerJvm = log4sLogger.jvm +lazy val log4sLoggerJs = log4sLogger.js +lazy val log4sLoggerNative = log4sLogger.native.settings(nativeSettings) -lazy val log4jLogger = - module(ProjectName("log4j"), crossProject(JVMPlatform, JSPlatform)) +lazy val log4jLogger = + module(ProjectName("log4j"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Logger with Log4j", Compile / unmanagedSourceDirectories ++= { @@ -195,11 +208,12 @@ lazy val log4jLogger = ), ) .dependsOn(core) -lazy val log4jLoggerJvm = log4jLogger.jvm -lazy val log4jLoggerJs = log4jLogger.js +lazy val log4jLoggerJvm = log4jLogger.jvm +lazy val log4jLoggerJs = log4jLogger.js +lazy val log4jLoggerNative = log4jLogger.native.settings(nativeSettings) -lazy val sbtLogging = - module(ProjectName("sbt-logging"), crossProject(JVMPlatform, JSPlatform)) +lazy val sbtLogging = + module(ProjectName("sbt-logging"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Logger with sbt logging", libraryDependencies ++= crossVersionProps( @@ -227,11 +241,12 @@ lazy val sbtLogging = ), ) .dependsOn(core) -lazy val sbtLoggingJvm = sbtLogging.jvm -lazy val sbtLoggingJs = sbtLogging.js +lazy val sbtLoggingJvm = sbtLogging.jvm +lazy val sbtLoggingJs = sbtLogging.js +lazy val sbtLoggingNative = sbtLogging.native.settings(nativeSettings) -lazy val cats = - module(ProjectName("cats"), crossProject(JVMPlatform, JSPlatform)) +lazy val cats = + module(ProjectName("cats"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Cats", libraryDependencies ++= libs.tests.hedgehogLibs ++ List( @@ -245,17 +260,18 @@ lazy val cats = ), ) .dependsOn(core % props.IncludeTest) -lazy val catsJvm = cats.jvm -lazy val catsJs = cats.js +lazy val catsJvm = cats.jvm +lazy val catsJs = cats.js +lazy val catsNative = cats.native.settings(nativeSettings) -lazy val testKit = - module(ProjectName("test-kit"), crossProject(JVMPlatform, JSPlatform)) +lazy val testKit = + module(ProjectName("test-kit"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Test Kit", libraryDependencies ++= libs.tests.hedgehogLibs ++ // libs.tests.hedgehogExtra ++ List( - libs.cats, + libs.cats ), libraryDependencies := libraryDependenciesRemoveScala3Incompatible( scalaVersion.value, @@ -263,11 +279,12 @@ lazy val testKit = ), ) .dependsOn(core % props.IncludeTest) -lazy val testKitJvm = testKit.jvm -lazy val testKitJs = testKit.js +lazy val testKitJvm = testKit.jvm +lazy val testKitJs = testKit.js +lazy val testKitNative = testKit.native.settings(nativeSettings) -lazy val catsEffect = - module(ProjectName("cats-effect"), crossProject(JVMPlatform, JSPlatform)) +lazy val catsEffect = + module(ProjectName("cats-effect"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Cats Effect", libraryDependencies ++= libs.tests.hedgehogLibs ++ List(libs.effectieCatsEffect2 % Test), @@ -278,11 +295,12 @@ lazy val catsEffect = ) .settings(noPublish) .dependsOn(core % props.IncludeTest, cats) -lazy val catsEffectJvm = catsEffect.jvm -lazy val catsEffectJs = catsEffect.js +lazy val catsEffectJvm = catsEffect.jvm +lazy val catsEffectJs = catsEffect.js +lazy val catsEffectNative = catsEffect.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 := "Logger for F[_] - Cats Effect 3", libraryDependencies ++= libs.tests.hedgehogLibs ++ List( @@ -296,11 +314,12 @@ lazy val catsEffect3 = ) .settings(noPublish) .dependsOn(core % props.IncludeTest, cats) -lazy val catsEffect3Jvm = catsEffect3.jvm -lazy val catsEffect3Js = catsEffect3.js +lazy val catsEffect3Jvm = catsEffect3.jvm +lazy val catsEffect3Js = catsEffect3.js +lazy val catsEffect3Native = catsEffect3.native.settings(nativeSettings) -lazy val monix = - module(ProjectName("monix"), crossProject(JVMPlatform, JSPlatform)) +lazy val monix = + module(ProjectName("monix"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - Monix", libraryDependencies ++= libs.tests.hedgehogLibs ++ List(libs.effectieMonix % Test), @@ -311,13 +330,14 @@ lazy val monix = ) .settings(noPublish) .dependsOn(core % props.IncludeTest, cats) -lazy val monixJvm = monix.jvm -lazy val monixJs = monix.js +lazy val monixJvm = monix.jvm +lazy val monixJs = monix.js +lazy val monixNative = monix.native.settings(nativeSettings) -lazy val testCatsEffectWithSlf4jLogger = +lazy val testCatsEffectWithSlf4jLogger = testProject( ProjectName("cats-effect-slf4j"), - crossProject(JVMPlatform, JSPlatform), + crossProject(JVMPlatform, JSPlatform, NativePlatform), ) .settings( description := "Test Logger for F[_] - Logger with Slf4j", @@ -329,13 +349,14 @@ lazy val testCatsEffectWithSlf4jLogger = ) .settings(noPublish) .dependsOn(core % props.IncludeTest, slf4jLogger, catsEffect % props.IncludeTest) -lazy val testCatsEffectWithSlf4jLoggerJvm = testCatsEffectWithSlf4jLogger.jvm -lazy val testCatsEffectWithSlf4jLoggerJs = testCatsEffectWithSlf4jLogger.js +lazy val testCatsEffectWithSlf4jLoggerJvm = testCatsEffectWithSlf4jLogger.jvm +lazy val testCatsEffectWithSlf4jLoggerJs = testCatsEffectWithSlf4jLogger.js +lazy val testCatsEffectWithSlf4jLoggerNative = testCatsEffectWithSlf4jLogger.native.settings(nativeSettings) -lazy val testMonixWithSlf4jLogger = +lazy val testMonixWithSlf4jLogger = testProject( ProjectName("monix-slf4j"), - crossProject(JVMPlatform, JSPlatform), + crossProject(JVMPlatform, JSPlatform, NativePlatform), ) .settings( description := "Test Logger for F[_] - Logger with Slf4j", @@ -347,13 +368,14 @@ lazy val testMonixWithSlf4jLogger = ) .settings(noPublish) .dependsOn(core % props.IncludeTest, slf4jLogger, monix % props.IncludeTest) -lazy val testMonixWithSlf4jLoggerJvm = testMonixWithSlf4jLogger.jvm -lazy val testMonixWithSlf4jLoggerJs = testMonixWithSlf4jLogger.js +lazy val testMonixWithSlf4jLoggerJvm = testMonixWithSlf4jLogger.jvm +lazy val testMonixWithSlf4jLoggerJs = testMonixWithSlf4jLogger.js +lazy val testMonixWithSlf4jLoggerNative = testMonixWithSlf4jLogger.native.settings(nativeSettings) -lazy val testCatsEffectWithLog4sLogger = +lazy val testCatsEffectWithLog4sLogger = testProject( ProjectName("cats-effect-log4s"), - crossProject(JVMPlatform, JSPlatform), + crossProject(JVMPlatform, JSPlatform, NativePlatform), ) .settings( description := "Test Logger for F[_] - Logger with Log4s", @@ -365,13 +387,14 @@ lazy val testCatsEffectWithLog4sLogger = ) .settings(noPublish) .dependsOn(core % props.IncludeTest, log4sLogger, catsEffect % props.IncludeTest) -lazy val testCatsEffectWithLog4sLoggerJvm = testCatsEffectWithLog4sLogger.jvm -lazy val testCatsEffectWithLog4sLoggerJs = testCatsEffectWithLog4sLogger.js +lazy val testCatsEffectWithLog4sLoggerJvm = testCatsEffectWithLog4sLogger.jvm +lazy val testCatsEffectWithLog4sLoggerJs = testCatsEffectWithLog4sLogger.js +lazy val testCatsEffectWithLog4sLoggerNative = testCatsEffectWithLog4sLogger.native.settings(nativeSettings) -lazy val testCatsEffectWithLog4jLogger = +lazy val testCatsEffectWithLog4jLogger = testProject( ProjectName("cats-effect-log4j"), - crossProject(JVMPlatform, JSPlatform), + crossProject(JVMPlatform, JSPlatform, NativePlatform), ) .settings( description := "Test Logger for F[_] - Logger with Log4j", @@ -383,8 +406,9 @@ lazy val testCatsEffectWithLog4jLogger = ) .settings(noPublish) .dependsOn(core % props.IncludeTest, log4jLogger, catsEffect % props.IncludeTest) -lazy val testCatsEffectWithLog4jLoggerJvm = testCatsEffectWithLog4jLogger.jvm -lazy val testCatsEffectWithLog4jLoggerJs = testCatsEffectWithLog4jLogger.js +lazy val testCatsEffectWithLog4jLoggerJvm = testCatsEffectWithLog4jLogger.jvm +lazy val testCatsEffectWithLog4jLoggerJs = testCatsEffectWithLog4jLogger.js +lazy val testCatsEffectWithLog4jLoggerNative = testCatsEffectWithLog4jLogger.native.settings(nativeSettings) lazy val docs = (project in file("docs-gen-tmp/docs")) .enablePlugins(MdocPlugin, DocusaurPlugin) @@ -484,7 +508,7 @@ lazy val props = final val GitHubUsername = "Kevin-Lee" final val RepoName = "logger-f" - final val Scala3Versions = List("3.0.2") + final val Scala3Versions = List("3.1.3") final val Scala2Versions = List("2.13.6", "2.12.13") // final val ProjectScalaVersion = Scala3Versions.head @@ -550,12 +574,12 @@ lazy val libs = lazy val effectieMonix: ModuleID = "io.kevinlee" %% "effectie-monix3" % props.EffectieVersion - object tests { + lazy val tests = new { lazy val hedgehogLibs: List[ModuleID] = List( - "qa.hedgehog" %% "hedgehog-core" % props.HedgehogVersion, + "qa.hedgehog" %% "hedgehog-core" % props.HedgehogVersion, "qa.hedgehog" %% "hedgehog-runner" % props.HedgehogVersion, - "qa.hedgehog" %% "hedgehog-sbt" % props.HedgehogVersion, + "qa.hedgehog" %% "hedgehog-sbt" % props.HedgehogVersion, ).map(_ % Test) lazy val hedgehogExtra = List( @@ -564,7 +588,7 @@ lazy val libs = lazy val extrasCats = "io.kevinlee" %% "extras-cats" % props.ExtrasVersion % Test - lazy val extrasConcurrent = "io.kevinlee" %% "extras-concurrent" % props.ExtrasVersion % Test + lazy val extrasConcurrent = "io.kevinlee" %% "extras-concurrent" % props.ExtrasVersion % Test lazy val extrasConcurrentTesting = "io.kevinlee" %% "extras-concurrent-testing" % props.ExtrasVersion % Test lazy val extrasHedgehogCatsEffect3 = "io.kevinlee" %% "extras-hedgehog-ce3" % props.ExtrasVersion % Test @@ -640,3 +664,7 @@ def projectCommonSettings(projectName: String, crossProject: CrossProject.Builde .settings( mavenCentralPublishSettings ) + +lazy val nativeSettings: SettingsDefinition = List( + Test / fork := false +) diff --git a/project/plugins.sbt b/project/plugins.sbt index 3d894ac7..03078202 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -15,6 +15,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)