From 40288a1aaddfc27e141771371d69122ce222a8d0 Mon Sep 17 00:00:00 2001 From: Sam Guymer Date: Thu, 17 May 2018 20:07:04 +1000 Subject: Extract MonadAsyncError implementations Extract MonadAsyncError implementations into their own projects to allow reuse by multiple backends. --- build.sbt | 176 +++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 104 insertions(+), 72 deletions(-) (limited to 'build.sbt') diff --git a/build.sbt b/build.sbt index ce57190..1f510e1 100644 --- a/build.sbt +++ b/build.sbt @@ -14,13 +14,9 @@ val commonSettings = Seq( ), publishArtifact in Test := false, publishMavenStyle := true, - scmInfo := Some( - ScmInfo(url("https://github.com/softwaremill/sttp"), - "scm:git:git@github.com/softwaremill/sttp.git")), - developers := List( - Developer("adamw", "Adam Warski", "", url("https://softwaremill.com"))), - licenses := ("Apache-2.0", - url("http://www.apache.org/licenses/LICENSE-2.0.txt")) :: Nil, + scmInfo := Some(ScmInfo(url("https://github.com/softwaremill/sttp"), "scm:git:git@github.com/softwaremill/sttp.git")), + developers := List(Developer("adamw", "Adam Warski", "", url("https://softwaremill.com"))), + licenses := ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.txt")) :: Nil, homepage := Some(url("http://softwaremill.com/open-source")), sonatypeProfileName := "com.softwaremill", // sbt-release @@ -36,9 +32,6 @@ val commonSettings = Seq( val akkaHttp = "com.typesafe.akka" %% "akka-http" % "10.1.1" val akkaStreams = "com.typesafe.akka" %% "akka-stream" % "2.5.12" -val monixVersion = "3.0.0-RC1" -val monix = "io.monix" %% "monix" % monixVersion - val scalaTest = "org.scalatest" %% "scalatest" % "3.0.5" lazy val rootProject = (project in file(".")) @@ -46,6 +39,9 @@ lazy val rootProject = (project in file(".")) .settings(publishArtifact := false, name := "sttp") .aggregate( core, + cats, + monix, + scalaz, akkaHttpBackend, asyncHttpClientBackend, asyncHttpClientFutureBackend, @@ -72,73 +68,90 @@ lazy val core: Project = (project in file("core")) ) ) -lazy val akkaHttpBackend: Project = (project in file("akka-http-backend")) +//----- implementations +lazy val cats: Project = (project in file("implementations/cats")) .settings(commonSettings: _*) .settings( - name := "akka-http-backend", - libraryDependencies ++= Seq( - akkaHttp, - // provided as we don't want to create a transitive dependency on a specific streams version, - // just as akka-http doesn't - akkaStreams % "provided" - ) - ) dependsOn core + name := "cats", + libraryDependencies ++= Seq("org.typelevel" %% "cats-effect" % "1.0.0-RC") + ) + .dependsOn(core % "compile->compile;test->test") -lazy val asyncHttpClientBackend: Project = (project in file( - "async-http-client-backend")) +lazy val monix: Project = (project in file("implementations/monix")) .settings(commonSettings: _*) .settings( - name := "async-http-client-backend", - libraryDependencies ++= Seq( - "org.asynchttpclient" % "async-http-client" % "2.4.7" - ) - ) dependsOn core + name := "monix", + libraryDependencies ++= Seq("io.monix" %% "monix" % "3.0.0-RC1") + ) + .dependsOn(core % "compile->compile;test->test") -lazy val asyncHttpClientFutureBackend: Project = (project in file( - "async-http-client-backend/future")) +lazy val scalaz: Project = (project in file("implementations/scalaz")) .settings(commonSettings: _*) .settings( - name := "async-http-client-backend-future" - ) dependsOn asyncHttpClientBackend + name := "scalaz", + libraryDependencies ++= Seq("org.scalaz" %% "scalaz-concurrent" % "7.2.22") + ) + .dependsOn(core % "compile->compile;test->test") -lazy val asyncHttpClientScalazBackend: Project = (project in file( - "async-http-client-backend/scalaz")) +//----- backends +//-- akka +lazy val akkaHttpBackend: Project = (project in file("akka-http-backend")) .settings(commonSettings: _*) .settings( - name := "async-http-client-backend-scalaz", + name := "akka-http-backend", libraryDependencies ++= Seq( - "org.scalaz" %% "scalaz-concurrent" % "7.2.23" + akkaHttp, + // provided as we don't want to create a transitive dependency on a specific streams version, + // just as akka-http doesn't + akkaStreams % "provided" ) - ) dependsOn asyncHttpClientBackend - -lazy val asyncHttpClientMonixBackend: Project = (project in file( - "async-http-client-backend/monix")) - .settings(commonSettings: _*) - .settings( - name := "async-http-client-backend-monix", - libraryDependencies ++= Seq(monix) - ) dependsOn asyncHttpClientBackend + ) + .dependsOn(core) -lazy val asyncHttpClientCatsBackend: Project = (project in file( - "async-http-client-backend/cats")) - .settings(commonSettings: _*) - .settings( - name := "async-http-client-backend-cats", - libraryDependencies ++= Seq( - "org.typelevel" %% "cats-effect" % "1.0.0-RC" +//-- async http client +lazy val asyncHttpClientBackend: Project = { + (project in file("async-http-client-backend")) + .settings(commonSettings: _*) + .settings( + name := "async-http-client-backend", + libraryDependencies ++= Seq( + "org.asynchttpclient" % "async-http-client" % "2.4.7" + ) ) - ) dependsOn asyncHttpClientBackend - -lazy val asyncHttpClientFs2Backend: Project = (project in file( - "async-http-client-backend/fs2")) - .settings(commonSettings: _*) - .settings( - name := "async-http-client-backend-fs2", - libraryDependencies ++= Seq( - "com.github.zainab-ali" %% "fs2-reactive-streams" % "0.5.1" + .dependsOn(core) +} + +def asyncHttpClientBackendProject(proj: String): Project = { + Project(s"asyncHttpClientBackend${proj.capitalize}", file(s"async-http-client-backend/$proj")) + .settings(commonSettings: _*) + .settings(name := s"async-http-client-backend-$proj") + .dependsOn(asyncHttpClientBackend) +} + +lazy val asyncHttpClientFutureBackend: Project = + asyncHttpClientBackendProject("future") + +lazy val asyncHttpClientScalazBackend: Project = + asyncHttpClientBackendProject("scalaz") + .dependsOn(scalaz) + +lazy val asyncHttpClientMonixBackend: Project = + asyncHttpClientBackendProject("monix") + .dependsOn(monix) + +lazy val asyncHttpClientCatsBackend: Project = + asyncHttpClientBackendProject("cats") + .dependsOn(cats) + +lazy val asyncHttpClientFs2Backend: Project = + asyncHttpClientBackendProject("fs2") + .settings( + libraryDependencies ++= Seq( + "com.github.zainab-ali" %% "fs2-reactive-streams" % "0.5.1" + ) ) - ) dependsOn asyncHttpClientBackend +//-- okhttp lazy val okhttpBackend: Project = (project in file("okhttp-backend")) .settings(commonSettings: _*) .settings( @@ -146,17 +159,23 @@ lazy val okhttpBackend: Project = (project in file("okhttp-backend")) libraryDependencies ++= Seq( "com.squareup.okhttp3" % "okhttp" % "3.10.0" ) - ) dependsOn core + ) + .dependsOn(core) -lazy val okhttpMonixBackend: Project = (project in file("okhttp-backend/monix")) - .settings(commonSettings: _*) - .settings( - name := "okhttp-backend-monix", - libraryDependencies ++= Seq(monix) - ) dependsOn okhttpBackend +def okhttpBackendProject(proj: String): Project = { + Project(s"okhttpBackend${proj.capitalize}", file(s"okhttp-backend/$proj")) + .settings(commonSettings: _*) + .settings(name := s"okhttp-backend-$proj") + .dependsOn(okhttpBackend) +} + +lazy val okhttpMonixBackend: Project = + okhttpBackendProject("monix") + .dependsOn(monix) lazy val circeVersion = "0.9.3" +//----- json lazy val circe: Project = (project in file("json/circe")) .settings(commonSettings: _*) .settings( @@ -190,7 +209,8 @@ lazy val braveBackend: Project = (project in file("metrics/brave-backend")) "io.zipkin.brave" % "brave-instrumentation-http-tests" % braveVersion % "test", scalaTest % "test" ) - ).dependsOn(core) + ) + .dependsOn(core) lazy val prometheusBackend: Project = (project in file("metrics/prometheus-backend")) .settings(commonSettings: _*) @@ -210,12 +230,24 @@ lazy val tests: Project = (project in file("tests")) name := "tests", libraryDependencies ++= Seq( akkaHttp, + akkaStreams, scalaTest, "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0", "com.github.pathikrit" %% "better-files" % "3.4.0", "ch.qos.logback" % "logback-classic" % "1.2.3", "org.scala-lang" % "scala-compiler" % scalaVersion.value - ).map(_ % "test"), - libraryDependencies += akkaStreams, - ) dependsOn (core, akkaHttpBackend, asyncHttpClientFutureBackend, asyncHttpClientScalazBackend, -asyncHttpClientMonixBackend, asyncHttpClientCatsBackend, asyncHttpClientFs2Backend, okhttpMonixBackend) + ).map(_ % "test") + ) + .dependsOn( + core % "compile->compile;test->test", + cats % "compile->compile;test->test", + monix % "compile->compile;test->test", + scalaz % "compile->compile;test->test", + akkaHttpBackend, + asyncHttpClientFutureBackend, + asyncHttpClientScalazBackend, + asyncHttpClientMonixBackend, + asyncHttpClientCatsBackend, + asyncHttpClientFs2Backend, + okhttpMonixBackend + ) -- cgit v1.2.3