[2.2.1 Scala] Running a Play subproject from sbt

661 views
Skip to first unread message

Brandon Gauthier

unread,
May 22, 2014, 6:15:56 PM5/22/14
to play-fr...@googlegroups.com
Hello,

I am trying to run a Play sub project from a larger sbt root project without needing to use the project switching commands. An example of the project layout can be found on GitHub and is described below:

Project Layout:
root
├───cli
  └─── ...(Command Line Project, Has a "main(...)")...
├───common
  └─── ...(Library Project)...
├───core
  └─── ...(Library Project)...
├───project
  └─── ...(sbt stuff)...
├───web
  └─── ...(Play Project)...
└───build.sbt

root/build.sbt:
name := "root"

version
:= "0.0.0-SNAPSHOT"

lazy val root
= project.in(file("."))
 
.aggregate(common, core, cli, web)

lazy val common
= project

lazy val core
= project
 
.dependsOn(common)

lazy val cli
= project
 
.dependsOn(common, core)
 
lazy val web
= project
 
.settings(play.Project.playScalaSettings: _*)
 
.dependsOn(common, core)


Currently the cli sub-project can be run via "cli/run" however when trying to run the web project with "web/run" I get the following exception:

> web/run
java
.lang.RuntimeException: */*:playRunHooks is undefined.
        at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last web/compile:run for the full output.
[error] (web/compile:run) */
*:playRunHooks is undefined.
[error] Total time: 0 s, completed May 22, 2014 5:36:36 PM

I can proved the full stack trace if needed.

I can run the web project buy using the following project switching commands:

> project web
[info] Set current project to web (in build file:file:/{{redacted to remove my username}}/Workspace/test/)
[web] $ run


--- (Running the application from SBT, auto-reloading is enabled) ---


[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

The Questions:
  1. Can someone explain why the web project (and Play) run correctly via project switching but not with "web/run"?
  2. Is there something I can do to my build make "web/run" work or is this a limitation of Play's sbt plugin?
  3. If this is a limitation of Play's sbt plugin what work would need to be done to change it?
--Brandon

Dima Golubets

unread,
Jun 9, 2014, 4:26:40 PM6/9/14
to play-fr...@googlegroups.com
Hi Brandon, 
I've met the same problem.. I wonder if you have solved it.

Brandon Gauthier

unread,
Jun 9, 2014, 6:27:05 PM6/9/14
to play-fr...@googlegroups.com, dgol...@gmail.com
No I have not. At my development shop we have just taken the approach of "Play is Different" and we use the project switching commands for Play projects and {projectname}/run for everything else. It is a pain: some of our automated scripts that call sbt had to be rewritten and it confuses new team members.

I have done a bit more research and discovered this interesting behavior:

> web/run
java
.lang.RuntimeException: */*:playRunHooks is undefined.
        at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last web/compile:run for the full output.
[error] (web/compile:run) */
*:playRunHooks is undefined.
[error] Total time: 0 s, completed Jun 9, 2014 5:53:25 PM
> show */*:playRunHooks
[error] No such setting/task
[error] show */
*:playRunHooks
[error]                      ^
> inspect */*:playRunHooks
[info] No entry for key.
[info] Description:
[info]
[info] Delegates:
[info]  */*:playRunHooks
[info] Related:
[info]  web/*:playRunHooks
>
show web/*:playRunHooks
[info] List()
[success] Total time: 0 s, completed Jun 9, 2014 5:53:44 PM
> inspect web/*:playRunHooks
[info] Task: scala.collection.Seq[play.PlayRunHook]
[info] Description:
[info]
[info] Provided by:
[info]  {file:/{{redacted to remove my username}}/Workspace/test/}web/*:playRunHooks
[info] Defined at:
[info]  {{redacted to remove my username}}/Workspace/test/web/build.sbt:11
[info] Dependencies:
[info]  web/*:playOnStarted
[info]  web/*:playOnStopped
[info] Delegates:
[info]  web/*:playRunHooks
[info]  {.}/*:playRunHooks
[info]  */*:playRunHooks

So it looks like playRunHooks may not be scoped correctly in the case of Play as a sub-project. I also could be 100% wrong, there is a lot of magic going on in the Play sbt plugin and I have not spent a lot of time studying it.

I would really like some of the Play core developers to chime in: What is going on here? Is Play as a sub-project a supported or recommended configuration? 

Once again I'm sorry I can't be of more help,
--Brandon

Eugene Yokota

unread,
Dec 11, 2014, 9:58:08 AM12/11/14
to play-fr...@googlegroups.com, dgol...@gmail.com
I think this is a bug in Play 2.2. See https://github.com/playframework/playframework/issues/3731 that I reported.
Play 2.3 looks ok.

-eugene
Reply all
Reply to author
Forward
0 new messages