Skip to content

Commit

Permalink
guava dep is optional again, GuavaInterop extracted from JavaInterop
Browse files Browse the repository at this point in the history
  • Loading branch information
ghik committed Dec 4, 2017
1 parent bc5a889 commit ce484ba
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ lazy val `commons-core` = project
sourceDirsSettings(_ / "jvm"),
libraryDependencies ++= Seq(
"com.google.code.findbugs" % "jsr305" % jsr305Version % Optional,
"com.google.guava" % "guava" % guavaVersion,
"com.google.guava" % "guava" % guavaVersion % Optional,
),
)

Expand Down Expand Up @@ -257,6 +257,7 @@ lazy val `commons-mongo` = project
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
"com.google.guava" % "guava" % guavaVersion,
"org.mongodb" % "mongodb-driver-core" % mongoVersion,
"org.mongodb" % "mongodb-driver" % mongoVersion % Optional,
"org.mongodb" % "mongodb-driver-async" % mongoVersion % Optional,
Expand All @@ -278,6 +279,7 @@ lazy val `commons-redis` = project
.settings(
jvmCommonSettings,
libraryDependencies ++= Seq(
"com.google.guava" % "guava" % guavaVersion,
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package jiop

import java.util.concurrent.{Executor, TimeUnit}

import com.avsystem.commons.jiop.GuavaUtils._
import com.avsystem.commons.jiop.GuavaInterop._
import com.avsystem.commons.misc.Sam
import com.google.common.util.concurrent.{FutureCallback, Futures, ListenableFuture, SettableFuture}
import com.google.common.{base => gbase}

import scala.annotation.unchecked.uncheckedVariance
import scala.concurrent.{Await, CanAwait, ExecutionException, TimeoutException}
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, CanAwait, ExecutionException, TimeoutException}

trait GuavaUtils {
trait GuavaInterop {
type GFunction[F, T] = gbase.Function[F, T]
type GSupplier[T] = gbase.Supplier[T]
type GPredicate[T] = gbase.Predicate[T]
Expand All @@ -31,7 +31,7 @@ trait GuavaUtils {
new DecorateFutureAsGuava(fut)
}

object GuavaUtils {
object GuavaInterop extends GuavaInterop {
class DecorateFutureAsScala[T](private val gfut: ListenableFuture[T]) extends AnyVal {
def asScala: Future[T] = gfut match {
case FutureAsListenableFuture(fut) => fut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ trait JavaInterop extends AnyRef
with JFunctionUtils
with JStreamUtils
with JOptionalUtils
with GuavaUtils

object JavaInterop extends JavaInterop
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.util.stream.{Collectors, DoubleStream, IntStream, LongStream}

import com.google.common.util.concurrent.{MoreExecutors, SettableFuture}
import org.scalatest.FunSuite
import GuavaInterop._

import scala.concurrent.Await
import scala.concurrent.duration.Duration
Expand Down

0 comments on commit ce484ba

Please sign in to comment.