Skip to content
Permalink
Browse files

[reactivemongo] Manage connection handler per actor, so that an singl…

…e ActorSystem can manage several handlers. Documentation about driver manager with SBT or Specs2.
  • Loading branch information
cchantep
cchantep committed Oct 30, 2014
1 parent b7b9c7f commit bd6763c3e1d513d05cfefbb887e20a672b1c71db
@@ -4,36 +4,14 @@ import Keys._
trait ReactiveMongo { deps: Dependencies
def scalacPlugin: Project

val reactiveMongoVer = settingKey[String]("Reactive Mongo version")

// Shared dependency
val reactiveMongoLib = "org.reactivemongo" %% "reactivemongo"
val reactiveResolvers = Seq(
"Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/releases/",
"Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/")

private lazy val reactiveMongoGen =
Project(id = "reactive-mongo-sbt",
base = file("project") / "reactive-mongo-sbt").settings(
name := "reactive-mongo-sbt",
javacOptions in Test ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
autoScalaLibrary := false,
scalacOptions += "-feature",
resolvers ++= reactiveResolvers,
reactiveMongoVer in ThisBuild := {
if (scalaVersion.value startsWith "2.11") "0.10.5.0.akka23"
else "0.10.0"
},
libraryDependencies ++= Seq(
reactiveMongoLib % reactiveMongoVer.value,
"org.javassist" % "javassist" % "3.18.2-GA")
)
"Sonatype Snapshots".at(
"https://oss.sonatype.org/content/repositories/snapshots/"))

lazy val generatedClassDirectory = settingKey[File](
"Directory where classes get generated")

lazy val generatedClasses = taskKey[Seq[(File, String)]]("Generated classes")

lazy val reactiveMongo =
Project(id = "reactive-mongo", base = file("reactive-mongo")).settings(
name := "reactive-mongo",
@@ -56,45 +34,13 @@ trait ReactiveMongo { deps: Dependencies ⇒
},
resolvers ++= reactiveResolvers,
libraryDependencies ++= Seq(
reactiveMongoLib % reactiveMongoVer.value,
"org.reactivemongo" %% "reactivemongo" % "0.10.5.0.akka23",
"com.jsuereth" %% "scala-arm" % "1.4",
"com.chuusai" % "shapeless" % "2.0.0" % Test cross CrossVersion.
binaryMapped {
case "2.10" => scalaVersion.value
case x => x
},
specs2Test),
generatedClassDirectory := {
val dir = target.value / "generated_classes"
if (!dir.exists) dir.mkdirs()
dir
},
generatedClasses <<= Def.task {
val cp = (fullClasspath in (reactiveMongoGen, Compile)).value
val cl = classpath.ClasspathUtilities.toLoader(cp.files)
val genClass = cl loadClass "acolyte.reactivemongo.ActorSystemGenerator"
val generator = genClass.newInstance.
asInstanceOf[{def writeTo(out: File): Array[File] }]
val outdir = generatedClassDirectory.value
val generated: Array[File] = generator writeTo outdir

generated.foldLeft(Seq[(File, String)]()) { (s, f) =>
val path = f.getAbsolutePath
s :+ (f -> path.drop(outdir.getAbsolutePath.length+1))
}
} dependsOn(compile in (reactiveMongoGen, Compile)),
managedClasspath in Compile := {
val cp = (managedClasspath in Compile).value
cp :+ Attributed.blank(generatedClassDirectory.value)
},
managedClasspath in Test := { // Same for test
val cp = (managedClasspath in Test).value
cp :+ Attributed.blank(generatedClassDirectory.value)
},
compile in Compile <<= (compile in Compile) dependsOn generatedClasses,
mappings in (Compile, packageBin) := {
val ms = mappings.in(Compile, packageBin).value
ms ++ generatedClasses.value // add generated classes to package
}
).dependsOn(/*reactiveMongoGen, */scalacPlugin)
specs2Test)
).dependsOn(scalacPlugin)
}

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit bd6763c

Please sign in to comment.
You can’t perform that action at this time.