Skip to content

Commit fcdae6d

Browse files
committed
Merge pull request #92 from tuplejump/develop
upgrading to Play 2.5
2 parents b32d3e6 + b60babe commit fcdae6d

File tree

110 files changed

+219
-8785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+219
-8785
lines changed

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The play-compatible-version depends on the version of Playframework being used,
4848
| 2.2.x | 0.6.4 | 2.10 |
4949
| 2.3.x | 0.7.1 | 2.10, 2.11 |
5050
| 2.4.x | 0.8.1 (support for injected routes generator) | 2.11 |
51+
| 2.5.x | 0.9.0 | 2.11 |
5152

5253

5354
3) Import Yeoman classes in the project build adding the following import to `project/Build.scala`,
@@ -84,6 +85,17 @@ Using >= 0.7.1
8485

8586
```
8687

88+
Using >= 0.9.0 (auto-plugin)
89+
90+
```scala
91+
val appSettings = Seq(version := appVersion, libraryDependencies ++= appDependencies) ++
92+
Yeoman.yeomanSettings
93+
94+
val main = Project(appName, file(".")).enablePlugins(play.PlayScala,Yeoman).settings(
95+
// Add your own project settings here
96+
appSettings: _*
97+
)
98+
```
8799

88100
Note: If you're using build.sbt instead of the full scala build, you need to place the 2 additions above into `build.sbt` as follows:
89101

@@ -123,6 +135,12 @@ lazy val root = (project in file(".")).enablePlugins(PlayScala)
123135
Yeoman.yeomanSettings ++ Yeoman.withTemplates
124136
```
125137

138+
Using >= 0.9.0 (auto-plugin)
139+
140+
```scala
141+
lazy val root = (project in file(".")).enablePlugins(PlayScala,Yeoman)
142+
```
143+
126144
5) Add yeoman routes to the project, appending the following line in conf/routes files,
127145

128146
```
@@ -142,8 +160,8 @@ GET / com.tuplejump.playYeoman.Yeoman.redirectRoot(base="/ui/")
142160
143161
```
144162

145-
If using, Play's injected routes generator, prefixing the route with `@` will work except for `yeoman.Routes`. It can be used as is.
146-
163+
Note: If using 0.8.1 and Play's injected routes generator, prefixing the route with `@` will work except for `yeoman.Routes`. It can be used as is.
164+
This is specific to version 0.8.1. From version 0.9.0, `InjectedRoutesGenerator` is default.
147165

148166
6) Start play/sbt in your project folder,
149167

@@ -250,18 +268,27 @@ Using >= 0.7.1
250268
251269
```
252270

271+
Using >= 0.9.0
272+
273+
```
274+
lazy val root = (project in file(".")).enablePlugins(PlayScala,Yeoman)
275+
276+
Yeoman.withTemplates
277+
```
278+
253279
* Once that is done play will compile the templates from yeoman directory too, and you can use them in your controllers. This helps you keep all your UI files together under the yeoman directory ('ui' by default)
254280

255-
* Look at the yo-demo and yo-injection-demo projects for details!
281+
* Look at the yo-demo!
256282

257-
Note: Starting from 0.7.1, play-yeoman supports compilation of views from the yeoman directory but cannot recompile them when they are modified with the server running. You will need to stop the server and start it again.
283+
For versions 0.7.1 to 0.8.1, you need to run `grunt` prior to compile else the template code will not be generated. This is not required if you execute `dist` or `stage` directly since they have a dependency on grunt.
258284

259-
* If you use scala template support, you need to run grunt prior to compile else the template code will not be generated. This is not required if you execute run or stage directly since they have a dependency on grunt.
285+
From 0.9.0 onwards, the views in yeoman directory are automatically compiled to generate template code.
260286

261287
### Taking it to production
262288

263289
From 0.6.3, play-yeoman updates Play's 'stage' and 'dist' tasks to depend on the grunt task. Thus you don't need any additional step putting this in production. when you run either `sbt dist` or `sbt stage` it will automatically run grunt as part of the build!
264290

291+
From 0.9.0, a boolean key `runGruntInDist` has been provided for helping with Heroku. It can be set to `false` and the yeoman distDirectory should be copied manually.
265292

266293
### Configuring the yeoman directory paths for Play
267294

notes/0.9.0.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
New in this release
2+
3+
+ Support for using Play 2.5.
4+
+ Auto-plugin
5+
+ additional config `runGruntInDist` (related to #87)
6+
+ `compile` depends on `grunt` when scala Templates are enabled

play-yeoman/app/com/tuplejump/playYeoman/Yeoman.scala

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
package com.tuplejump.playYeoman
22

3+
import java.io.File
4+
import javax.inject.Inject
5+
6+
import controllers.Assets
37
import play.api._
48
import play.api.mvc._
5-
import controllers.Assets
6-
import play.api.Play.current
7-
import java.io.File
8-
import scala.concurrent.Future
9-
import scala.concurrent.ExecutionContext.Implicits.global
9+
1010
import scala.collection.JavaConverters._
11+
import scala.concurrent.ExecutionContext.Implicits.global
12+
import scala.concurrent.Future
1113

12-
object Yeoman extends Controller {
14+
class Yeoman @Inject() (environment: play.api.Environment,
15+
devAssets: DevAssets) extends Controller {
16+
17+
def at(file: String): Action[AnyContent] = atHandler(file)
1318

1419
def index = Action.async {
1520
request =>
@@ -20,6 +25,9 @@ object Yeoman extends Controller {
2025
}
2126
}
2227

28+
def assetHandler(file: String): Action[AnyContent] = {
29+
Assets.at("/public", file)
30+
}
2331

2432
def redirectRoot(base: String = "/ui/") = Action {
2533
request =>
@@ -30,34 +38,21 @@ object Yeoman extends Controller {
3038
}
3139
}
3240

33-
def assetHandler(file: String): Action[AnyContent] = {
34-
Assets.at("/public", file)
35-
}
36-
37-
lazy val atHandler: String => Action[AnyContent] = if (Play.isProd) assetHandler(_: String) else DevAssets.assetHandler(_: String)
38-
39-
def at(file: String): Action[AnyContent] = atHandler(file)
40-
41-
42-
}
43-
44-
/**
45-
* Class added to support injected route generator (Play 2.4 onwards)
46-
*/
47-
class Yeoman extends Controller {
48-
def index = Yeoman.index
41+
lazy val atHandler: String => Action[AnyContent] = if (environment.mode==Mode.Prod) {
42+
assetHandler(_: String)
43+
} else devAssets.assetHandler(_: String)
4944

50-
def redirectRoot(base: String = "/ui/") = Yeoman.redirectRoot(base)
5145
}
5246

53-
object DevAssets extends Controller {
47+
class DevAssets @Inject() (environment: play.api.Environment,
48+
configuration: play.api.Configuration) extends Controller {
5449
// paths to the grunt compile directory or else the application directory, in order of importance
55-
val runtimeDirs = Play.configuration.getStringList("yeoman.devDirs")
50+
val runtimeDirs = configuration.getStringList("yeoman.devDirs")
5651
val basePaths: List[java.io.File] = runtimeDirs match {
57-
case Some(dirs) => dirs.asScala.map(Play.application.getFile _).toList
58-
case None => List(Play.application.getFile("ui/.tmp"), Play.application.getFile("ui/app"),
52+
case Some(dirs) => dirs.asScala.map(environment.getFile _).toList
53+
case None => List(environment.getFile("ui/.tmp"), environment.getFile("ui/app"),
5954
//added ui to defaults since the newer projects have bower_components in ui directory instead of ui/app/components
60-
Play.application.getFile("ui"))
55+
environment.getFile("ui"))
6156
}
6257

6358
/**

play-yeoman/build.sbt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
val appName = "play-yeoman"
2+
val appVersion = "0.9.0"
3+
4+
val main = Project(appName, file(".")).enablePlugins(PlayScala).settings(
5+
version := appVersion,
6+
scalaVersion in Global := "2.11.7",
7+
// crossScalaVersions := Seq("2.11.7"),
8+
homepage := Some(url("https://github.com/tuplejump/play-yeoman")),
9+
organization := "com.tuplejump",
10+
organizationName := "Tuplejump Software Pvt. Ltd.",
11+
organizationHomepage := Some(new java.net.URL("http://www.tuplejump.com")),
12+
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
13+
publishMavenStyle := true,
14+
publishTo <<= version {
15+
(v: String) =>
16+
val nexus = "https://oss.sonatype.org/"
17+
if (v.trim.endsWith("SNAPSHOT"))
18+
Some("snapshots" at nexus + "content/repositories/snapshots")
19+
else
20+
Some("releases" at nexus + "service/local/staging/deploy/maven2")
21+
},
22+
publishArtifact in Test := false,
23+
pomIncludeRepository := {
24+
_ => false
25+
},
26+
pomExtra := (
27+
<scm>
28+
<url>git@github.com:tuplejump/play-yeoman.git</url>
29+
<connection>scm:git:git@github.com:tuplejump/play-yeoman.git</connection>
30+
</scm>
31+
<developers>
32+
<developer>
33+
<id>eraoferrors</id>
34+
<name>Shiti Saxena</name>
35+
<url>https://twitter.com/eraoferrors</url>
36+
</developer>
37+
<developer>
38+
<id>milliondreams</id>
39+
<name>Rohit Rai</name>
40+
<url>https://twitter.com/milliondreams</url>
41+
</developer>
42+
</developers>)
43+
)

play-yeoman/project/Build.scala

Lines changed: 0 additions & 58 deletions
This file was deleted.

play-yeoman/project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.8
1+
sbt.version=0.13.11

play-yeoman/project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ logLevel := Level.Warn
55
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
66

77
// Use the Play sbt plugin for Play projects
8-
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")
8+
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.0")
99

0 commit comments

Comments
 (0)