I am attempting to develop a Play 2.0 web application alongside a core Java module and other Java clients using SBT. Is it possible to configure this in a way where the Play application is still built properly?
I have developed a small one-off Play 2.0 app before but I have zero experience working with SBT directly. So far I have come up with the following directory structure and project/Build.scala
file.
root/
|---common/
|
|---client1/
|---client2/
|
|---webapp/
| |---app/
| |---conf/
| |---public/
|
|---project/
.
object ApplicationBuild extends Build {
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
)
val common = Project("hi-common", file("common"))
val client1 = Project("hi-client1", file("client1")).dependsOn(common)
val client2 = Project("hi-client2", file("client2")).dependsOn(common)
val webapp = PlayProject("hi-webapp", appVersion, appDependencies, path = file("webapp"), mainLang = JAVA).settings(
// Add your own project settings here
).dependsOn(common)
val root = Project("hi", file(".")).aggregate(client1, client2, webapp)
}
Running sbt clean package
seems to work appropriately for the common
, client1
, and client2
modules but the webapp
module is not packaged to a point where I can run webapp/target/start
.
What can I do to achieve this as a single build with proper output?
The problem here is that simply running the package
goal is not enough to generate a start script for you. It will assemble the fully package web application but without a single means of starting it.
My goal was the deployment to Heroku who conveniently provide a plugin which will generate this start script for you. The repository for the plugin's inclusion is added by default with a Play 2.0 web application so all you have to do is modify the commands that you are using for the build to sbt clean compile stage
and you will find an start
script in the webapp/target/
folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With