From 19523c65c342cbd1c6ac3803860708c9eb52860a 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 | 148 ++++++++++++++++++++-------------- project/plugins.sbt | 5 ++ 4 files changed, 96 insertions(+), 61 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 9ecf459f..2b6b45ee 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 6f445568..d627d1c6 100644 --- a/build.sbt +++ b/build.sbt @@ -69,30 +69,41 @@ 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, logbackMdcMonix3Jvm, logbackMdcMonix3Js, + logbackMdcMonix3Native, 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( @@ -106,10 +117,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( @@ -121,11 +133,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( @@ -137,11 +150,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 ++= { @@ -197,11 +211,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( @@ -229,11 +244,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( @@ -248,10 +264,11 @@ 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 logbackMdcMonix3 = module(ProjectName("logback-mdc-monix3"), crossProject(JVMPlatform, JSPlatform)) +lazy val logbackMdcMonix3 = module(ProjectName("logback-mdc-monix3"), crossProject(JVMPlatform, JSPlatform, NativePlatform)) .settings( description := "Logger for F[_] - logback MDC context map support for Monix 3", libraryDependencies ++= Seq( @@ -271,11 +288,12 @@ lazy val logbackMdcMonix3 = module(ProjectName("logback-mdc-monix3"), crossPr monix % Test, slf4jLogger % Test, ) -lazy val logbackMdcMonix3Jvm = logbackMdcMonix3.jvm -lazy val logbackMdcMonix3Js = logbackMdcMonix3.js +lazy val logbackMdcMonix3Jvm = logbackMdcMonix3.jvm +lazy val logbackMdcMonix3Js = logbackMdcMonix3.js +lazy val logbackMdcMonix3Native = logbackMdcMonix3.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 ++ @@ -289,11 +307,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), @@ -304,11 +323,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( @@ -322,11 +342,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), @@ -337,13 +358,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", @@ -355,13 +377,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", @@ -373,13 +396,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", @@ -391,13 +415,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", @@ -409,8 +434,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) @@ -510,7 +536,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 @@ -683,3 +709,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)