forked from playframework/playframework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes playframework#1390. * Implemented reverse router aggregation * Replaced routesFiles task with sources in routes task * Added scripted test for testing router aggregation * Added support for compiling/including .sbt code snippets in the documentation
- Loading branch information
Showing
27 changed files
with
348 additions
and
97 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
documentation/manual/detailedTopics/build/AggregatingReverseRouters.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Aggregating reverse routers | ||
|
||
In some situations you want to share reverse routers between sub projects that are not dependent on each other. | ||
|
||
For example, you might have a `web` sub project, and an `api` sub project. These sub projects may have no dependence on each other, except that the `web` project wants to render links to the `api` project (for making AJAX calls), while the `api` project wants to render links to the `web` (rendering the web link for a resource in JSON). In this situation, it would be convenient to use the reverse router, but since these projects don't depend on each other, you can't. | ||
|
||
Play's routes compiler offers a feature that allows a common dependency to generate the reverse routers for projects that depend on it so that the reverse routers can be shared between those projects. This is configured using the `aggregateReverseRoutes` sbt configuration item, like this: | ||
|
||
@[content](code/aggregate.sbt) | ||
|
||
In this setup, the reverse routers for `api` and `web` will be generated as part of the `common` project. Meanwhile, the forwards routers for `api` and `web` will still generate forwards routers, but not reverse routers, because their reverse routers have already been generated in the `common` project which they depend on, so they don't need to generate them. | ||
|
||
> Note that the `common` project has a type of `Project` explicitly declared. This is because there is a recursive reference between it and the `api` and `web` projects, through the `dependsOn` method and `aggregateReverseRoutes` setting, so the Scala type checker needs an explicit type somewhere in the chain of recursion. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
documentation/manual/detailedTopics/build/code/aggregate.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//#content | ||
lazy val common: Project = (project in file("common")) | ||
.enablePlugins(PlayScala) | ||
.settings( | ||
aggregateReverseRoutes := Seq(api, web) | ||
) | ||
|
||
lazy val api = (project in file("api")) | ||
.enablePlugins(PlayScala) | ||
.dependsOn(common) | ||
|
||
lazy val web = (project in file("web")) | ||
.enablePlugins(PlayScala) | ||
.dependsOn(common) | ||
//#content | ||
|
||
lazy val root = (project in file(".")) | ||
.enablePlugins(PlayScala) | ||
.dependsOn(api, web) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//#default | ||
name := "foo" | ||
|
||
version := "1.0-SNAPSHOT" | ||
|
||
libraryDependencies ++= Seq( | ||
jdbc, | ||
anorm, | ||
cache | ||
) | ||
|
||
lazy val root = (project in file(".")).enablePlugins(PlayScala) | ||
//#default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.