1
votes

https://github.com/jasongoodwin/play21-multimodule-demo has the code. I've recreated this problem on 3 different projects. I don't know what's up. once you put the aggregate and dependsOn in the build.scala file the project throws an error when trying to start play.

[info] Loading global plugins from /Users/jgoodwin/.sbt/plugins [info] Loading project definition from /Users/jgoodwin/Development/src/ninjakeyboard/test/tmp/play21-multimodule-demo/project [error] java.lang.ExceptionInInitializerError [error] Use 'last' for the full log. Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q

Build file

import sbt._ import Keys._ import play.Project._

object ApplicationBuild extends Build {

val appName = "multimodule-demo" val appVersion = "1.0-SNAPSHOT" //val scalaVersion = "2.10.0"

val appDependencies = Seq( // Add your project dependencies here, jdbc, anorm )

val buildSettings = ( scalaVersion := "2.10.0" )

val main = play.Project(appName, appVersion, appDependencies, path = file("web")).settings( // Add your own project settings here ).aggregate(testmodule).dependsOn(testmodule)

val testmodule = Project( "testmodule", file("testmodlue"), settings = buildSettings )

}

2
Probably going to need more information since there's too many open variables. It could come down to repos not being available, a conflict between target and runtime SBT versions. Can you get the full log during load?crockpotveggies
The github repository with the application is there - you can check it out and try. Way too many variables for me to provide anything more useful than the actual code itself.JasonG
hmmmm...at this point i might suggest copying an existing module and using it as a "template". then doing a DIFF to see if you missed anything. it's a lot of work to sift through the whole repocrockpotveggies
I've recreated the problem 3 times. This is just a stock new project with a g8 template used for the submodule. I followed the play documentation and this is the result. Can't find anyone who has done this on 2.1 yet.JasonG
Your project structure looks completely different compared to a regular Play project.. I have no experience with SBT, just the play commands, perhaps the structure is causing crashes.adis

2 Answers

3
votes

I noticed in your github build.scala that testmodule is declared (and initialized) after the main module, thus the null exception during project loading. I made the same mistake and putting the modules in the right order made it work. I just started playing with Play2 and Scala, but I believe the use of lazy val could also help.

1
votes

Try to create a fresh project:

  1. Run command: play new MyApp
  2. Run play clean eclipse
  3. Make dir modules (inside MyApp)
  4. Run command play new MyModule
  5. Run command play clean eclipse
  6. Rename controller to MyModuleCon, and change the routes file
  7. Run command play clean publish-local
  8. Add to your MyApp Build.scala the dependency: "mymodule" % "mymodule_2.10" % "1.0-SNAPSHOT"
  9. Rename main route to app.routes (because modules has also routes, although it can be deleted!)
  10. On the main project run: play dependencies eclipse

Voila, you have your submodule, see my github: https://github.com/adis-me/PlayModuleExample

Just run play run and visit main project at: http://localhost:9000 and then visit the submodule: http://localhost:9000/module.

This should do the trick, for you, I think!

EDIT: 2013-03-27

Changing the above configuration to a real sub project setup, follow these steps:

  1. Run on MyApp: play clean
  2. Change MyApp's Build.scala file:

object ApplicationBuild extends Build {

  val appName         = "MyAppp"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    javaCore,
    javaJdbc,
    javaEbean
  )

  val subproject = play.Project(
    "sub-project", appVersion, appDependencies, path = file("modules/MyModule")
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here      
  ).dependsOn(subproject).aggregate(subproject)

}
  1. Run commands: play clean eclipse
  2. Run commands: play run

That's it, you can no visit the same urls as above mentioned. It can be that your idea does not recognize the classes from your subproject, just reference the MyModule project as referenced library for the main project, and you are good to go.

Good luck!