Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbt compile hangs after adding autowire to a play 2.4.2 project #40

Open
gitsumanth opened this issue Aug 4, 2015 · 0 comments
Open

Comments

@gitsumanth
Copy link

I've created a bare minimum play-scala project using activator, added autowire and upickle. Then added the necessary autowire.Server implementation. Sbt compile just hangs and doesnt quit, i had to kill the process. I might be doing something wrong here, although i've tried to stay as close as possible to the samples in this repo. Here's the controller.

package controllers

import play.api._
import play.api.mvc.Results._
import play.api.mvc._
import upickle.default.{Reader => UpickleReader, Writer => UpickleWriter}
import autowire._

class Application extends Controller {

  def index = Action {
    Ok(views.html.index("Your new application is ready."))
  }

  def something = Action.async { request =>
    AutowireRouter.route[TestApi](TestApiImpl)(autowire.Core.Request(
      "controllers/TestApi/getPeople".split(","),
      upickle.default.read[Map[String, String]](request.body.asText.getOrElse("")))).map{ people =>
      Ok(people)
    }.recover{case e => InternalServerError(e.getMessage)}
  }

}

case class TestModel(name: String, age: Int)

trait TestApi {
  val people: Seq[TestModel] = Seq(TestModel("a",1), TestModel("b",2), TestModel("c",3), TestModel("d",4))
  def getPeople(howMany: Int): Seq[TestModel]
}

object TestApiImpl extends TestApi {
  def getPeople(howMany: Int) = people.take(howMany)
}

object AutowireRouter extends Server[String, UpickleReader, UpickleWriter] {
  def read[Result: UpickleReader](input: String) = upickle.default.read[Result](input)
  def write[Result: UpickleWriter](result: Result) = upickle.default.write(result)
}

build.sbt

name := """tester"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,
  specs2 % Test,
  "com.lihaoyi" %% "autowire" % "0.2.5",
  "com.lihaoyi" %% "upickle" % "0.3.4"
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant