Search code examples
javaplayframeworkroutesplayframework-2.3subproject

Play Framework 2.3.4 routes redirection to subproject


quite new with Play framework, but I tried to setup subproject for my main project but when I tried to redirect the route from the main project to subproject, it couldnt recognise the subproject variable. I have followed based on the documentation here PlaySubProject

My main project structure is as illustrated below:

Main
   app
   conf
      application.conf
      routes
   modules
      sub
         app
         conf
            sub.routes
         build.sbt
   logs
   project
   public
   target
   test
   activator
   activator-launch-1.2.10.jar
   build.sbt

This is my main build.sbt file:

name := """Main"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava).aggregate(sub).dependsOn(sub)

lazy val sub = (project in file("modules/sub")).enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs
)

and my subproject build.sbt is as follows:

name := """Subproject"""

version := "1.0-SNAPSHOT"

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs
)

Finally, this is my main routes file.

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET        /                    controllers.Application.index()

# Map static resources from the /public folder to the /assets URL path
GET        /assets/*file        controllers.Assets.at(path="/public", file)

# SUB's
->  /sub    sub.Routes

The problem is in this routes file, it cannot even recognize sub variable on the last line at sub.Routes. How to solve this problem?


Solution

  • I'm not sure about your specific issue, but I setup a fully working and reasonably well-documented multi-project example at https://github.com/josh-padnick/play-multiproject-template. This is based on Play 2.2.3 (not 2.3.x), but it should be pretty close to what you need.