1
votes

I'm trying to migrate a play 2.3 (java) project which uses SBTSubProjects to play 2.4 and now I'm having some routing-problems.

sample project showing my issue

The project uses three subprojects (admin, website and common):

build.sbt:
lazy val root = (project in file(".")).enablePlugins(PlayJava).dependsOn(admin, website).aggregate(website, admin)
lazy val common = (project in file("modules/common")).enablePlugins(PlayJava)
lazy val admin = (project in file("modules/admin")).enablePlugins(PlayJava).dependsOn(common)
lazy val website = (project in file("modules/website")).enablePlugins(PlayJava).dependsOn(common)
routesGenerator := InjectedRoutesGenerator

conf/routes:
-> /admin admin.Routes
-> /website website.Routes

With 2.3 it was possible to start the app with "activator run" using the "root"-project and then by calling /admin or /website it used the corresponding subprojects-routes. Doing the same with 2.4 I'm getting only the admin-routes with a wrong path to the assets. When switching the active project to admin or website with "project" the projects routing is working as expected.

How do I get the same behaviour as before? Thanks

1

1 Answers

2
votes

I had exactly the same issue when upgrading from 2.3 to 2.4, and got it fixed. The key is to set a default application.conf for the root project

In the build.sbt of the root project, add this line to make sure it always uses the root configuration

Keys.javaOptions+="-Dconfig.file=conf/application.conf"

This might also be the cause of your issue, because without a setting, Play might pick any of the application.conf, and if it picks the one from a sub project, which in your case, seem to be the admin project, and that only has the admin routes.