Tuesday, April 26, 2016


I put my handlebars project in to the sub-project and stucked with the problem of reverse routing.

I used it in the assets helper

public static CharSequence asset(final String url) throws Exception{
 return controllers.routes.Assets.versioned(new controllers.Assets.Asset(url)).toString();
controllers.routes package was missing, because it generates in the process of the root project generation, and root project depends on the handlebars sub projects.

For sure I was not the first who faced with this problem. There is a long story issue. And there is a documentation as well. So if you met this problem then aggregateReverseRoutes setting would help you. The reason for this post is that it somewhat hard to recognize that "Aggregating reverse routers" is exactly about this problem, I saw similar questions on the StackOverflow.

My project definition section of the build.sbt in the root project

lazy val handlebars = (project in file("modules/handlebars"))
     aggregateReverseRoutes := Seq(root)

lazy val root: Project = (project in file("."))
Two thing here you need to pay attention.

First, aggregateReverseRoutes := Seq(root) says that handlebars need reverse routing from the root project.

Second, lazy val root: Project implicit variable type must be used because of recursion.

No comments:

Post a Comment