i'm currently working on a Play ! 2.1.1 application defining multiple subprojects. Here is my Build.scala :
val lfamName = "lfam"
val lfamVersion = "1.0-SNAPSHOT"
val lfamDirectory = "subprojects/" + lfamName
lazy val lfam = play.Project(lfamName, lfamVersion, appDependencies, path = file(lfamDirectory))
val mainName = "main"
val mainVersion = "1.0-SNAPSHOT"
lazy val main = play.Project(mainName, mainVersion, appDependencies)
.settings().dependsOn(lfam).aggregate(lfam)
The resulting struture :
app
└ controllers
└> Application.scala
└ models
└ views
└> index.scala.html
└ assets
└ stylesheets
└> main.less
conf
└> application.conf
└> routes
subprojects
└ lfam
└ conf
└> lfam.routes
└ app/controllers
└> Application.scala
└> Assets.scala
└ app/models
└ app/views
└> index.scala.html
└ assets
└ stylesheets
└> main.less
The sources :
routes
GET / controllers.Application.index
-> /lfam lfam.Routes
GET /assets/*file controllers.Assets.at(path="/public", file)
lfam.routes
GET / controllers.lfam.Application.index
GET /assets/*file controllers.lfam.Assets.at(path="/public", file)
Assets.scala
package controllers.lfam
object Assets extends controllers.AssetsBuilder
Application.scala (just the package name changes between project)
package controllers(.lfam)
import play.api._
import play.api.mvc._
object Application extends Controller {
def index = Action {
Ok(views.html.index())
}
}
main.less (main project)
@main-color: #0000ff;
h1 {
color: @main-color;
}
main.less (lfam project)
@main-color: #ff0000;
h1 {
color: @main-color;
}
index.scala.html (main project)
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="@routes.Assets.at("stylesheets/main.css")">
</head>
<body>
<h1>Header</h1>
</body>
</html>
index.scala.html (lfam project)
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="@lfam.routes.Assets.at("stylesheets/main.css")">
</head>
<body>
<h1>Header</h1>
</body>
</html>
When the subproject index is displayed (/lfam/) the header is still blue. But if i rename the main.less file from subproject to lfam.less (and the corresponding in html) the header becomes red(as expected).
Is it possible to have multiple assets in multiple subprojects, with the same name ? How is play not serving me the right css file in the first case but finding the second one ?
Thanks