From 9b6fc679512fb7230c01dc7fb57b2bb322b3f4f3 Mon Sep 17 00:00:00 2001 From: Lachlan O'Dea Date: Wed, 16 Feb 2022 19:59:10 +1100 Subject: [PATCH] Add Scala 3 support. (#190) --- .github/workflows/ci.yml | 2 +- README.md | 3 +-- build.sbt | 1 + project/BuildHelper.scala | 31 ++++++++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cab749a..61c1f0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: fail-fast: false matrix: java: ['8', '11', '17'] - scala: ['2.12.15', '2.13.8'] + scala: ['2.12.15', '2.13.8', '3.1.1'] steps: - name: Checkout current branch uses: actions/checkout@v2.4.0 diff --git a/README.md b/README.md index 2914d8c..4069be6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ | --- | --- | --- | --- | --- | | [![Project stage][Stage]][Stage-Page] | ![CI][Badge-CI] | [![Release Artifacts][Badge-SonatypeReleases]][Link-SonatypeReleases] | [![Snapshot Artifacts][Badge-SonatypeSnapshots]][Link-SonatypeSnapshots] | [![Discord][Badge-Discord]][Link-Discord] | -This library provides interoperability between **Monix 3.4** and **ZIO 1 and ZIO 2**. +This library provides interoperability between **Monix 3.4** and **ZIO 1 and ZIO 2**. Both JVM and Scala.js are supported. ## Tasks @@ -54,7 +54,6 @@ def zioBasedProcessor(s: String): Task[Unit] = ??? val zioEffects = for { zioRuntime <- ZIO.runtime[Any] - monixTask = _ <- ZIO.fromMonixTask { monixBasedApi(s => zioBasedProcessor(s).toMonixTaskUsingRuntime(zioRuntime) diff --git a/build.sbt b/build.sbt index 596bea6..0d153d4 100644 --- a/build.sbt +++ b/build.sbt @@ -37,6 +37,7 @@ lazy val interopMonix = crossProject(JSPlatform, JVMPlatform) .in(file("interop-monix")) .enablePlugins(BuildInfoPlugin) .settings(stdSettings("zio-interop-monix")) + .settings(dottySettings) .settings(crossProjectSettings) .settings(testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))) .settings(buildInfoSettings("zio.interop.monix")) diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index 380fb73..619ebe9 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -25,6 +25,7 @@ object BuildHelper { val Scala212: String = versions("2.12") val Scala213: String = versions("2.13") + val Scala3: String = versions("3.1") private val stdOptions = Seq( "-deprecation", @@ -63,8 +64,36 @@ object BuildHelper { buildInfoPackage := packageName ) + val dottySettings = Seq( + scalacOptions ++= { + if (scalaVersion.value == Scala3) + Seq("-noindent") + else + Seq() + }, + Compile / doc / sources := { + val old = (Compile / doc / sources).value + if (scalaVersion.value == Scala3) + Nil + else + old + }, + Test / parallelExecution := { + val old = (Test / parallelExecution).value + if (scalaVersion.value == Scala3) + false + else + old + } + ) + def extraOptions(scalaVersion: String, optimize: Boolean) = CrossVersion.partialVersion(scalaVersion) match { + case Some((3, _)) => + Seq( + "-language:implicitConversions", + "-Xignore-scala2-macros" + ) case Some((2, 13)) => Seq( "-Ywarn-unused:params,-implicits" @@ -151,7 +180,7 @@ object BuildHelper { def stdSettings(prjName: String) = Seq( name := s"$prjName", - crossScalaVersions := Seq(Scala212, Scala213), + crossScalaVersions := Seq(Scala212, Scala213, Scala3), ThisBuild / scalaVersion := Scala213, scalacOptions ++= stdOptions ++ extraOptions(scalaVersion.value, optimize = !isSnapshot.value), Test / parallelExecution := true,