Search code examples
playframeworksbtakkamicroservicesmulti-project

Play akka microservice as multi project


I am learning about microservices. For demonstration purposes I want to combine a frontend: play with some backend services: Akka. SBTsmulti-project` compilation should be well suited for this. However I face some problems:

  • The main class cannot be found - even if I navigate into the correct sub-module.
  • The dependencies are not resolved, even though they seem to be defined correctly.

To follow along: https://github.com/dataplayground/microservice


Solution

  • Dependencies must be explicitly imported as such:

    lazy val backend = (project in file(".")).aggregate(api)
    
    lazy val api = project.in(file("modules/api"))
      .settings(libraryDependencies ++= backendCommon)
    
    lazy val backendCommon = Seq(
      "com.typesafe.akka" %% "akka-actor" % "2.3.11",
      "com.typesafe.akka" %% "akka-testkit" % "2.3.11" % "test",
      "org.scalatest" %% "scalatest" % "2.2.4" % "test")