Skip to content

Commit

Permalink
upgrades, some prep for scala 3 and remove cats-tagless dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jbwheatley committed Apr 26, 2021
1 parent 6debbe3 commit 8e51ee8
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 50 deletions.
57 changes: 32 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,49 @@ promptTheme := PromptTheme(
)
)

def maxClassFileName(v: String) =
def scalaOptions(v: String) =
CrossVersion.partialVersion(v) match {
case Some((2, 13)) => List.empty[String]
case Some((3, _)) => List("-Ykind-projector")
case _ => List("-Xmax-classfile-name", "100")
}

def commonDependencies(v: String) =
List(
Libraries.amqpClient,
Libraries.catsEffect,
Libraries.fs2Core,
Libraries.scalaTest % Test,
Libraries.scalaCheck % Test,
Libraries.scalaTestPlusScalaCheck % Test
) ++
(CrossVersion.partialVersion(v) match {
case Some((3, _)) => List.empty
case _ =>
List(
compilerPlugin(Libraries.kindProjector),
compilerPlugin(Libraries.betterMonadicFor)
)
})

val commonSettings = List(
organizationName := "ProfunKtor",
startYear := Some(2017),
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://fs2-rabbit.profunktor.dev/")),
headerLicense := Some(HeaderLicense.ALv2("2017-2020", "ProfunKtor")),
scalacOptions in (Compile, doc) ++= List("-no-link-warnings"),
scalacOptions ++= maxClassFileName(scalaVersion.value),
Compile / doc / scalacOptions ++= List("-no-link-warnings"),
scalacOptions ++= scalaOptions(scalaVersion.value),
scalacOptions --= List("-Wunused:params"),
libraryDependencies ++= {
List(
compilerPlugin(Libraries.kindProjector),
compilerPlugin(Libraries.betterMonadicFor),
Libraries.amqpClient,
Libraries.catsEffect,
Libraries.fs2Core,
Libraries.scalaTest % Test,
Libraries.scalaCheck % Test,
Libraries.scalaTestPlusScalaCheck % Test
)
},
libraryDependencies ++= commonDependencies(scalaVersion.value),
resolvers += "Apache public" at "https://repository.apache.org/content/groups/public/",
scalafmtOnCompile := true,
mimaPreviousArtifacts := Set(organization.value %% moduleName.value % "3.0.1")
mimaPreviousArtifacts := Set(organization.value %% moduleName.value % "4.0.0-RC1")
)

def CoreDependencies(scalaVersionStr: String): List[ModuleID] =
List(
Libraries.scodecCats,
Libraries.catsTagless,
Libraries.logback % Test
)

Expand All @@ -74,9 +81,9 @@ def JsonDependencies(scalaVersionStr: String): List[ModuleID] =
def ExamplesDependencies(scalaVersionStr: String): List[ModuleID] =
List(
Libraries.logback % "runtime",
Libraries.monix,
Libraries.zioCore,
Libraries.zioCats,
// Libraries.monix,
// Libraries.zioCore,
// Libraries.zioCats,
Libraries.dropwizard,
Libraries.dropwizardJmx
)
Expand All @@ -94,7 +101,7 @@ lazy val noPublish = List(
publish := {},
publishLocal := {},
publishArtifact := false,
skip in publish := true
publish / skip := true
)

lazy val `fs2-rabbit-root` = project
Expand All @@ -107,14 +114,14 @@ lazy val `fs2-rabbit` = project
.in(file("core"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= CoreDependencies(scalaVersion.value))
.settings(parallelExecution in Test := false)
.settings(Test / parallelExecution := false)
.enablePlugins(AutomateHeaderPlugin)

lazy val `fs2-rabbit-circe` = project
.in(file("json-circe"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= JsonDependencies(scalaVersion.value))
.settings(parallelExecution in Test := false)
.settings(Test / parallelExecution := false)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`fs2-rabbit`)

Expand All @@ -125,7 +132,7 @@ lazy val tests = project
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin)
.settings(libraryDependencies ++= TestsDependencies(scalaVersion.value))
.settings(parallelExecution in Test := false)
.settings(Test / parallelExecution := false)
.dependsOn(`fs2-rabbit`, `fs2-rabbit-testkit`)

lazy val examples = project
Expand Down Expand Up @@ -169,7 +176,7 @@ lazy val microsite = project
Map("title" -> "Code of Conduct")
)
),
micrositeExtraMdFilesOutput := (resourceManaged in Compile).value / "jekyll",
micrositeExtraMdFilesOutput := (Compile / resourceManaged).value / "jekyll",
micrositeGitterChannel := true,
micrositeGitterChannelUrl := "profunktor-dev/fs2-rabbit",
micrositePushSiteWith := GitHub4s,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package dev.profunktor.fs2rabbit.algebra

import cats.effect.Sync
import cats.syntax.functor._
import cats.tagless.{Derive, FunctorK}
import dev.profunktor.fs2rabbit.arguments._
import dev.profunktor.fs2rabbit.model._

Expand Down Expand Up @@ -122,7 +121,7 @@ object Binding {
}.void
}

implicit val functorK: FunctorK[Binding] = Derive.functorK
implicit def toBindingOps[F[_]](binding: Binding[F]): BindingOps[F] = new BindingOps[F](binding)
}

trait Binding[F[_]] {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2017-2020 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.fs2rabbit.algebra

import cats.~>
import dev.profunktor.fs2rabbit.model._

private[fs2rabbit] final class BindingOps[F[_]](val binding: Binding[F]) extends AnyVal {
def mapK[G[_]](fK: F ~> G): Binding[G] = new Binding[G] {
def bindQueue(
channel: AMQPChannel,
queueName: QueueName,
exchangeName: ExchangeName,
routingKey: RoutingKey,
args: QueueBindingArgs
): G[Unit] =
fK(binding.bindQueue(channel, queueName, exchangeName, routingKey, args))

def bindQueueNoWait(
channel: AMQPChannel,
queueName: QueueName,
exchangeName: ExchangeName,
routingKey: RoutingKey,
args: QueueBindingArgs
): G[Unit] =
fK(binding.bindQueueNoWait(channel, queueName, exchangeName, routingKey, args))

def unbindQueue(
channel: AMQPChannel,
queueName: QueueName,
exchangeName: ExchangeName,
routingKey: RoutingKey,
args: QueueUnbindArgs
): G[Unit] =
fK(binding.unbindQueue(channel, queueName, exchangeName, routingKey, args))

def bindExchange(
channel: AMQPChannel,
destination: ExchangeName,
source: ExchangeName,
routingKey: RoutingKey,
args: ExchangeBindingArgs
): G[Unit] =
fK(binding.bindExchange(channel, destination, source, routingKey, args))

def bindExchangeNoWait(
channel: AMQPChannel,
destination: ExchangeName,
source: ExchangeName,
routingKey: RoutingKey,
args: ExchangeBindingArgs
): G[Unit] =
fK(binding.bindExchangeNoWait(channel, destination, source, routingKey, args))

def unbindExchange(
channel: AMQPChannel,
destination: ExchangeName,
source: ExchangeName,
routingKey: RoutingKey,
args: ExchangeUnbindArgs
): G[Unit] =
fK(binding.unbindExchange(channel, destination, source, routingKey, args))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package dev.profunktor.fs2rabbit.algebra

import cats.effect.Sync
import cats.syntax.functor._
import cats.tagless.{Derive, FunctorK}
import dev.profunktor.fs2rabbit.arguments._
import dev.profunktor.fs2rabbit.config.declaration.{DeclarationExchangeConfig, DeclarationQueueConfig}
import dev.profunktor.fs2rabbit.effects.BoolValue.syntax._
Expand Down Expand Up @@ -91,7 +90,7 @@ object Declaration {
}.void
}

implicit val functorK: FunctorK[Declaration] = Derive.functorK
implicit def toDeclarationOps[F[_]](declaration: Declaration[F]): DeclarationOps[F] = new DeclarationOps(declaration)
}

trait Declaration[F[_]] {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2017-2020 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.fs2rabbit.algebra

import cats.~>
import dev.profunktor.fs2rabbit.config.declaration.{DeclarationExchangeConfig, DeclarationQueueConfig}
import dev.profunktor.fs2rabbit.model._

private[fs2rabbit] final class DeclarationOps[F[_]](val declaration: Declaration[F]) extends AnyVal {
def mapK[G[_]](fK: F ~> G): Declaration[G] = new Declaration[G] {
def declareExchange(channel: AMQPChannel, exchangeConfig: DeclarationExchangeConfig): G[Unit] =
fK(declaration.declareExchange(channel, exchangeConfig))

def declareExchangeNoWait(value: AMQPChannel, exchangeConfig: DeclarationExchangeConfig): G[Unit] =
fK(declaration.declareExchangeNoWait(value, exchangeConfig))

def declareExchangePassive(channel: AMQPChannel, exchangeName: ExchangeName): G[Unit] =
fK(declaration.declareExchangePassive(channel, exchangeName))

def declareQueue(channel: AMQPChannel): G[QueueName] =
fK(declaration.declareQueue(channel))

def declareQueue(channel: AMQPChannel, queueConfig: DeclarationQueueConfig): G[Unit] =
fK(declaration.declareQueue(channel, queueConfig))

def declareQueueNoWait(channel: AMQPChannel, queueConfig: DeclarationQueueConfig): G[Unit] =
fK(declaration.declareQueueNoWait(channel, queueConfig))

def declareQueuePassive(channel: AMQPChannel, queueName: QueueName): G[Unit] =
fK(declaration.declareQueuePassive(channel, queueName))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package dev.profunktor.fs2rabbit.algebra

import cats.effect.Sync
import cats.syntax.functor._
import cats.tagless.{Derive, FunctorK}
import dev.profunktor.fs2rabbit.config.deletion
import dev.profunktor.fs2rabbit.config.deletion.{DeletionExchangeConfig, DeletionQueueConfig}
import dev.profunktor.fs2rabbit.effects.BoolValue.syntax._
Expand Down Expand Up @@ -64,7 +63,7 @@ object Deletion {
}.void
}

implicit val functorK: FunctorK[Deletion] = Derive.functorK
implicit def toDeletionOps[F[_]](deletion: Deletion[F]): DeletionOps[F] = new DeletionOps[F](deletion)
}

trait Deletion[F[_]] {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2017-2020 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.fs2rabbit.algebra

import cats.~>
import dev.profunktor.fs2rabbit.config.deletion._
import dev.profunktor.fs2rabbit.model._

private[fs2rabbit] final class DeletionOps[F[_]](val deletion: Deletion[F]) extends AnyVal {
def mapK[G[_]](fK: F ~> G): Deletion[G] = new Deletion[G] {
def deleteQueue(channel: AMQPChannel, config: DeletionQueueConfig): G[Unit] =
fK(deletion.deleteQueue(channel, config))

def deleteQueueNoWait(channel: AMQPChannel, config: DeletionQueueConfig): G[Unit] =
fK(deletion.deleteQueueNoWait(channel, config))

def deleteExchange(channel: AMQPChannel, config: DeletionExchangeConfig): G[Unit] =
fK(deletion.deleteExchange(channel, config))

def deleteExchangeNoWait(channel: AMQPChannel, config: DeletionExchangeConfig): G[Unit] =
fK(deletion.deleteExchangeNoWait(channel, config))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import cats.data.EitherT
import cats.effect.kernel.MonadCancel
import cats.~>
import cats.implicits._
import cats.tagless.implicits.toFunctorKOps
import dev.profunktor.fs2rabbit.algebra.ConnectionResource

final class RabbitClientOps[F[_]](val client: RabbitClient[F]) extends AnyVal {
Expand Down
32 changes: 15 additions & 17 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import sbt._
object Dependencies {

object Version {
val cats = "2.5.0"
val catsEffect = "3.0.1"
val fs2 = "3.0.1"
val circe = "0.13.0"
val amqpClient = "5.11.0"
val logback = "1.2.3"
val monix = "3.3.0"
val zio = "1.0.4-2"
val zioCats = "2.3.1.0"
val scodec = "1.0.0"
val dropwizard = "4.1.18"
val catsTagless = "0.12"
val cats = "2.6.0"
val catsEffect = "3.1.0"
val fs2 = "3.0.2"
val circe = "0.13.0"
val amqpClient = "5.12.0"
val logback = "1.2.3"
val monix = "3.3.0"
val zio = "1.0.4-2"
val zioCats = "2.3.1.0"
val scodec = "1.0.0"
val dropwizard = "4.1.18"

val kindProjector = "0.11.3"
val betterMonadicFor = "0.3.1"
Expand All @@ -28,11 +27,10 @@ object Dependencies {
object Libraries {
def circe(artifact: String): ModuleID = "io.circe" %% artifact % Version.circe

lazy val amqpClient = "com.rabbitmq" % "amqp-client" % Version.amqpClient
lazy val catsEffect = "org.typelevel" %% "cats-effect" % Version.catsEffect
lazy val fs2Core = "co.fs2" %% "fs2-core" % Version.fs2
lazy val scodecCats = "org.scodec" %% "scodec-cats" % Version.scodec
lazy val catsTagless = "org.typelevel" %% "cats-tagless-macros" % Version.catsTagless
lazy val amqpClient = "com.rabbitmq" % "amqp-client" % Version.amqpClient
lazy val catsEffect = "org.typelevel" %% "cats-effect" % Version.catsEffect
lazy val fs2Core = "co.fs2" %% "fs2-core" % Version.fs2
lazy val scodecCats = "org.scodec" %% "scodec-cats" % Version.scodec

// Compiler
lazy val kindProjector = "org.typelevel" % "kind-projector" % Version.kindProjector cross CrossVersion.full
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.9
sbt.version=1.5.1

0 comments on commit 8e51ee8

Please sign in to comment.