Skip to content

Commit

Permalink
Merge pull request #104 from Twizty/scala-2-13
Browse files Browse the repository at this point in the history
Added support for Scala 2.13
  • Loading branch information
gvolpe authored Jun 17, 2019
2 parents 2240242 + 84177db commit 7033971
Show file tree
Hide file tree
Showing 20 changed files with 307 additions and 50 deletions.
76 changes: 60 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name := """redis4cats-root"""

organization in ThisBuild := "dev.profunktor"

crossScalaVersions in ThisBuild := Seq("2.12.8")
crossScalaVersions in ThisBuild := Seq("2.12.8", "2.13.0")

sonatypeProfileName := "dev.profunktor"

Expand All @@ -16,6 +16,15 @@ promptTheme := PromptTheme(List(
text(_ => "redis4cats", fg(15)).padRight(" λ ")
))

def cond[A](condition: Boolean, t: => Seq[A], f: => Seq[A]): Seq[A] =
if (condition) {
t
} else {
f
}

def version(strVersion: String): Option[(Long, Long)] = CrossVersion.partialVersion(strVersion)

val commonSettings = Seq(
organizationName := "Redis client for Cats Effect & Fs2",
startYear := Some(2018),
Expand All @@ -26,14 +35,27 @@ val commonSettings = Seq(
compilerPlugin(Libraries.kindProjector cross CrossVersion.binary),
compilerPlugin(Libraries.betterMonadicFor),
Libraries.redisClient,
Libraries.catsEffect,
Libraries.catsLaws % Test,
Libraries.catsTestKit % Test,
Libraries.scalaTest % Test,
Libraries.scalaCheck % Test
),
) ++ cond(
version(scalaVersion.value) == Some(2, 12),
t = Seq(
Libraries212.catsEffect,
Libraries212.scalaTest % Test,
Libraries212.catsLaws % Test,
Libraries212.catsTestKit % Test,
),
f = Seq(
Libraries213.catsEffect,
Libraries213.scalaTest % Test,
Libraries213.catsLaws % Test,
Libraries213.catsTestKit % Test,
)),
resolvers += "Apache public" at "https://repository.apache.org/content/groups/public/",
scalacOptions ++= Seq("-Xmax-classfile-name", "80"),
scalacOptions ++= cond(
version(scalaVersion.value) == Some(2, 12),
t = Seq("-Xmax-classfile-name", "80"),
f = Seq.empty
),
scalafmtOnCompile := true,
publishTo := {
val sonatype = "https://oss.sonatype.org/"
Expand Down Expand Up @@ -73,42 +95,63 @@ lazy val `redis4cats-core` = project.in(file("modules/core"))

lazy val `redis4cats-log4cats` = project.in(file("modules/log4cats"))
.settings(commonSettings: _*)
.settings(libraryDependencies += Libraries.log4CatsCore)
.settings(libraryDependencies ++=
cond(
version(scalaVersion.value) == Some(2, 12),
t = Seq(Libraries212.log4CatsCore),
f = Seq(Libraries213.log4CatsCore)
)
)
.settings(parallelExecution in Test := false)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`redis4cats-core`)

lazy val `redis4cats-effects` = project.in(file("modules/effects"))
lazy val `redis4cats-effects` = project.in(file("modules/effects"))
.settings(commonSettings: _*)
.settings(parallelExecution in Test := false)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`redis4cats-core`)

lazy val `redis4cats-streams` = project.in(file("modules/streams"))
.settings(commonSettings: _*)
.settings(libraryDependencies += Libraries.fs2Core)
.settings(libraryDependencies ++=
cond(
version(scalaVersion.value) == Some(2, 12),
t = Seq(Libraries212.fs2Core),
f = Seq(Libraries213.fs2Core)
)
)
.settings(parallelExecution in Test := false)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`redis4cats-core`)

lazy val examples = project.in(file("modules/examples"))
.settings(commonSettings: _*)
.settings(noPublish)
.settings(libraryDependencies += Libraries.log4CatsSlf4j)
.settings(libraryDependencies ++=
cond(
version(scalaVersion.value) == Some(2, 12),
t = Seq(Libraries212.log4CatsSlf4j),
f = Seq(Libraries213.log4CatsSlf4j)
)
)
.settings(libraryDependencies += Libraries.logback % "runtime")
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`redis4cats-log4cats`)
.dependsOn(`redis4cats-effects`)
.dependsOn(`redis4cats-streams`)

lazy val `redis4cats-test-support` = project.in(file("modules/test-support"))
lazy val `redis4cats-test-support` = project.in(file("modules/test-support"))
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= Seq(
Libraries.scalaTest,
Libraries.scalaCheck
)
libraryDependencies ++=
cond(
version(scalaVersion.value) == Some(2, 12),
t = Seq(Libraries212.scalaTest),
f = Seq(Libraries213.scalaTest)
)
)
.settings(libraryDependencies += Libraries.scalaCheck)
.settings(parallelExecution in Test := false)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`redis4cats-core`)
Expand All @@ -120,6 +163,7 @@ lazy val tests = project.in(file("modules/tests"))
.settings(noPublish)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`redis4cats-test-support` % Test)
.dependsOn(`redis4cats-core`)

lazy val microsite = project.in(file("site"))
.enablePlugins(MicrositesPlugin)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats

import scala.collection.convert.{DecorateAsJava, DecorateAsScala}

object JavaConversions extends DecorateAsJava with DecorateAsScala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats

import scala.collection.convert.{AsJavaExtensions, AsScalaExtensions}

object JavaConversions extends AsJavaExtensions with AsScalaExtensions
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import io.lettuce.core.{ RedisURI => JRedisURI }
import io.lettuce.core.cluster.{ SlotHash, RedisClusterClient => JClusterClient }
import io.lettuce.core.cluster.models.partitions.{ Partitions => JPartitions }

import scala.collection.JavaConverters._
import dev.profunktor.redis4cats.JavaConversions._

object RedisClusterClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import dev.profunktor.redis4cats.effect.{ JRFuture, Log }
import io.lettuce.core.masterslave.{ MasterSlave, StatefulRedisMasterSlaveConnection }
import io.lettuce.core.{ ReadFrom => JReadFrom, RedisURI => JRedisURI }

import scala.collection.JavaConverters._
import dev.profunktor.redis4cats.JavaConversions._

object RedisMasterSlave {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats.testutils

import org.scalatest.AsyncFunSuite

class Redis4CatsAsyncFunSuite extends AsyncFunSuite {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats.testutils

import org.scalatest.funsuite.AsyncFunSuite

class Redis4CatsAsyncFunSuite extends AsyncFunSuite {

}

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import java.util.concurrent.CompletableFuture

import cats.effect.{ ContextShift, IO }
import cats.syntax.all._
import org.scalatest.AsyncFunSuite
import dev.profunktor.redis4cats.testutils.Redis4CatsAsyncFunSuite

class JRFutureSpec extends AsyncFunSuite {
class JRFutureSpec extends Redis4CatsAsyncFunSuite {

implicit val cs: ContextShift[IO] = IO.contextShift(scala.concurrent.ExecutionContext.global)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private[redis4cats] class BaseRedis[F[_]: ContextShift, K, V](
extends RedisCommands[F, K, V]
with RedisConversionOps {

import scala.collection.JavaConverters._
import dev.profunktor.redis4cats.JavaConversions._

def async: F[RedisClusterAsyncCommands[K, V]] =
if (cluster) conn.clusterAsync else conn.async.widen[RedisClusterAsyncCommands[K, V]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import dev.profunktor.redis4cats.effect.JRFuture
import fs2.Stream
import io.lettuce.core.pubsub.StatefulRedisPubSubConnection

import scala.collection.JavaConverters._
import dev.profunktor.redis4cats.JavaConversions._

class LivePubSubStats[F[_]: Concurrent: ContextShift, K, V](
pubConnection: StatefulRedisPubSubConnection[K, V]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import dev.profunktor.redis4cats.effect.JRFuture
import io.lettuce.core.XReadArgs.StreamOffset
import io.lettuce.core.api.StatefulRedisConnection

import scala.collection.JavaConverters._
import dev.profunktor.redis4cats.JavaConversions._

private[streams] class RedisRawStreaming[F[_]: Concurrent: ContextShift, K, V](
val client: StatefulRedisConnection[K, V]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats.testutils

import org.scalatest.AsyncFunSuite

class Redis4CatsAsyncFunSuite extends AsyncFunSuite {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats.testutils

import org.scalatest.FunSuite

class Redis4CatsFunSuite extends FunSuite {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats.testutils

import org.scalatest.funsuite.AsyncFunSuite

class Redis4CatsAsyncFunSuite extends AsyncFunSuite {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2018-2019 ProfunKtor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.profunktor.redis4cats.testutils

import org.scalatest.funsuite.AnyFunSuite

class Redis4CatsFunSuite extends AnyFunSuite {

}
Loading

0 comments on commit 7033971

Please sign in to comment.