I want to test how sub projects work, especially how the routes
of the sub project are taken into account in main project (this was not visible before).
I have read the docs here: https://github.com/playframework/Play20/wiki/SBTSubProjects
What have I done: (after downloading play 2.1 RC3)
play new MainProject
modules
play new SubProject
On both projects: play eclipse
since play eclipsify
does not work anymore
In the main projects Build.scala
file:
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "MainProject"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
javaCore,
javaJdbc,
javaEbean
)
val subProject = Project("subproject", file("modules/SubProject"))
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
).dependsOn(subProject)
}
Now, in the main project I run:
play run
And I get the following errors:
[error] (MainProject/*:update) sbt.ResolveException: unresolved dependency: play#play_2.9.2;2.1-RC3: not found
[error] unresolved dependency: play#play-java_2.9.2;2.1-RC3: not found
[error] unresolved dependency: play#play-java-jdbc_2.9.2;2.1-RC3: not found
[error] unresolved dependency: play#play-java-ebean_2.9.2;2.1-RC3: not found
[error] unresolved dependency: play#play-test_2.9.2;2.1-RC3: not found
Note
I have tried to delete the Build.scala
from the subproject but I kep getting this error.
What am I doing wrong?
Create a New Play App To get to the local documentation for Play, navigate to localhost:9000/@documentation. After that, you can either use a basic code editor or import your project in IntelliJ or Eclipse by using ScalaIDE. The app source directory for Java, Scala, and client side source code.
The activator command can be used to create a new Play application. Activator allows you to select a template that your new application should be based off. For vanilla Play projects, the names of these templates are play-scala for Scala based Play applications, and play-java for Java based Play applications.
Finally got it working:
Build.scala
from the subproject.You need to rename the routes file of your sub project. In my example, to subProject.routes
. If you want to run your subproject in isolation you need to declare that routes must resolve to your subProject.routes. So add this in the application.conf
of your subProject:
application.router=subProject.Routes
In your main project, you need to import the routes from the subproject:
-> /subProject subProject.Routes
And the build file of the main project should look something like: example is from SCALA but s
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "MainProject"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
javaCore,
javaJdbc,
javaEbean
)
val subProject = play.Project(
appName + "-subProject", appVersion, path = file("modules/SubProject")
)
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
).dependsOn(subProject)
}
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