0

I have a simple project with two submodules, proja and projb. Proja contains trait UserController used in UserControllerImpl inside projb.

project on github: https://github.com/aswarcewicz/play-sbt-multimodule

root build.sbt:

name := """proj"""

version := "1.0-SNAPSHOT"

lazy val proja = Project(id = "proj-a", base = file("modules/proj-a"))
  .enablePlugins(PlayScala)

lazy val projb = Project(id = "proj-b", base = file("modules/proj-b"))
  .enablePlugins(PlayScala)
  .dependsOn(proja)
  .aggregate(proja)

lazy val root = Project(id = "proj", base = file("."))
  .enablePlugins(PlayScala)
  .dependsOn(proja, projb)
  .aggregate(proja, projb)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

and error from compiler:

modules/proj-b/app/controllers/UserControllerImpl.scala:5: not found: object controller [error] import controller._

/modules/proj-b/app/controllers/UserControllerImpl.scala:10: not found: type UserController [error] class UserControllerImpl extends Controller with UserController {

I have no idea what can be wrong.

biesior
  • 55,576
  • 10
  • 125
  • 182
user2860204
  • 151
  • 9

3 Answers3

1

You have some errors.

I will commit the changes that your project needs to work in following repository. https://github.com/martinscmb/play-sbt-multimodule

localhost:9000/test output:
{"user":{"name":"toto","age":25,"email":"toto@jmail.com","isAlive":true,"friend":{"name":"tata","age":20,"email":"tata@coldmail.com"}}}
martinscmb
  • 131
  • 6
0

You should change your SBT file to:

name := """proj"""

version := "1.0-SNAPSHOT"

lazy val root = Project(id = "proj", base = file("."))
  .enablePlugins(PlayScala)
  .aggregate(proja, projb)

lazy val proja = Project(id = "proj-a", base = file("modules/proj-a"))
  .enablePlugins(PlayScala)

lazy val projb = Project(id = "proj-b", base = file("modules/proj-b"))
  .enablePlugins(PlayScala)
  .dependsOn(proja)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

Add correct dependencies and reload your project.

Omid
  • 1,959
  • 25
  • 42
0

You want to define a commonSettings module and pass through everywhere:

import sbt.Keys._

lazy val commonSettings = Seq(
  scalaVersion := "2.11.7",
  routesGenerator := InjectedRoutesGenerator,
  version := "1.0-SNAPSHOT"
)

lazy val root = (project in file("."))
    .enablePlugins(PlayScala)
    .settings(commonSettings)
    .settings(Seq(name := """proj"""))
    .dependsOn(`proj-a`, `proj-b`)
    .aggregate(`proj-a`, `proj-b`)

lazy val `proj-b` = (project in file("modules/proj-b"))
  .enablePlugins(PlayScala)
  .settings(commonSettings)
  .dependsOn(`proj-a`).aggregate(`proj-a`)

lazy val `proj-a` = (project in file("modules/proj-a"))
  .enablePlugins(PlayScala)
  .settings(commonSettings)
Will Sargent
  • 4,346
  • 1
  • 31
  • 53