Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Rai committed Dec 7, 2014
2 parents 045c607 + fd0fd17 commit 588e6ba
Show file tree
Hide file tree
Showing 26 changed files with 1,341 additions and 995 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~

108 changes: 104 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,90 @@ How to use it?

1) Create a new play project or open an existing play project

2) Add the yeoman sbt plugin to the project. Edit project/plugins.sbt to add the following line,
2) Add the yeoman sbt plugin to the project. Edit `project/plugins.sbt` to add the following line,

```
addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "0.6.4")
addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "play-compatible-version")
```
play-compatible-version = 0.7.0 for Play 2.3.0 and 0.6.4 for Play 2.2.x

3) Import Yeoman classes in the project build adding the following import to project/Build.scala,
If you are really impatient or are using Scala 2.11, you can use the 0.7.1-SNAPSHOT using the following code.

```
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "0.7.1-SNAPSHOT")
```

You will also have to add the snapshot resolver to build (project/Build.scala orr build.sbt) file too,

```
resolvers += Resolver.sonatypeRepo("snapshots")
```


3) Import Yeoman classes in the project build adding the following import to `project/Build.scala`,

```scala

import com.tuplejump.sbt.yeoman.Yeoman

```

4) In the same file, add the yeoman settings to your Play project like this,

```
Using 0.6.4

```scala
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
Yeoman.yeomanSettings : _*
)

```


Using 0.7.0

```scala
val appSettings = Seq(version := appVersion, libraryDependencies ++= appDependencies) ++
Yeoman.yeomanSettings

val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings(
// Add your own project settings here
appSettings: _*
)

```


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:

Using 0.6.4

```scala

import com.tuplejump.sbt.yeoman.Yeoman

name := "play-project"

version := "1.0-SNAPSHOT"

libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache
)

play.Project.playJavaSettings ++ Yeoman.yeomanSettings

```

5) Add yeoman routes to the project, appending the following line in conf/routes files,

```
Expand Down Expand Up @@ -112,6 +171,27 @@ user yo-demo> sbt
```

Note: If you are using Scala Templates support in play-yeoman 0.7.0, ensure that "htmlmin" task is not called during the "build" since it does not understand Scala templates. This can be done by updating the build task in Gruntfile.js,

```
grunt.registerTask('build', [
'clean:dist',
'bower-install',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngmin',
'copy:dist',
'cdnify',
'cssmin',
'uglify',
'rev',
'usemin'/*,
'htmlmin' */
]);
```

10) Run your play application,

```
Expand All @@ -136,17 +216,37 @@ To use Scala templates you have 2 options,

* All you have to do to enable it is add Yeoman.withTemplates settings to the app settings, so your play project will now look like this,

Using 0.6.4

```
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
(Yeoman.yeomanSettings ++ Yeoman.withTemplates) : _*
)
```

Using 0.7.0

```
val appSettings = Seq(version := appVersion, libraryDependencies ++= appDependencies) ++
Yeoman.yeomanSettings ++
Yeoman.withTemplates
val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings(
// Add your own project settings here
appSettings: _*
)
```

* 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)

* Look at the yo-demo project for details!

Note: In 0.7.0, 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.

* 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.

### Taking it to production

Expand Down
32 changes: 32 additions & 0 deletions notes/0.7.0.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
This release, is a major upgrade, a long overdue one, to play-yeoman bringing the required play version to 2.3.0. This will also be thee first release in which I don't think I have any contributions and the major work comes from single commiter, *Shiti* ([@eraoferrors](http://twitter.com/eraoferrors) | [github](https://github.com/Shiti))

New in this release -

+ Support Play 2.3.0
+ Built on sbt-web
+ Using start script generated from stage task works. Github issue #36

Some other good things for the project are -

+ Our "known active" user base is over 25 developers
+ We have got 180 stars in Github!

So go ahead and enjoy the new build!
Please do report any issues you find to the project on Github.

This release would not have been possible without -

+ [Shiti Saxena](https://github.com/Shiti)
+ [Anton Fedchenko](https://github.com/kompot)
+ [Patrick Schulz](https://github.com/pschulz)
+ [Pietari Kettunen](https://github.com/pietrotull)
+ [Oliver](https://github.com/OliverKK)
+ [Scott Holodak](https://github.com/scottt732)
+ [Justin](https://github.com/thejchap)
+ [Radzislaw Galler](https://github.com/rajish)
+ [Markus Klink] (https://github.com/justjoheinz)
+ [Robert Grundler](https://github.com/pulse00)
+ [Diwa](https://github.com/diwa)
+ [Jan Tammen](https://github.com/jtammen)
+ [Mark White](https://github.com/mark9white)

1 change: 1 addition & 0 deletions play-yeoman/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dist
/.project
/RUNNING_PID
/.settings

36 changes: 14 additions & 22 deletions play-yeoman/app/com/tuplejump/playYeoman/Yeoman.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@ package com.tuplejump.playYeoman

import play.api._
import play.api.mvc._
import controllers.{ExternalAssets, Assets}
import controllers.Assets
import play.api.Play.current
import java.io.File
import play.api.libs.MimeTypes
import scala.concurrent.Future
import scala.collection.JavaConversions._
import play.api.libs.concurrent.Execution.Implicits._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.collection.JavaConverters._

object Yeoman extends Controller {

def index = Action.async {
request =>
if (request.path.endsWith("/")) {
//AsyncResult {
at("index.html").apply(request)
//}
} else {
Future {
Redirect(request.path + "/")
}
Future(Redirect(request.path + "/"))
}
}

Expand All @@ -36,26 +30,22 @@ object Yeoman extends Controller {
}
}

def assetHandler(file: String) = {
Play.configuration.getString("yeoman.distDir") match {
case Some(distDir) => Assets.at(distDir, file)
case None => Assets.at("/ui/dist", file)
}
def assetHandler(file: String): Action[AnyContent] = {
Assets.at("/public", file)
}

lazy val atHandler = if (Play.isProd) assetHandler(_: String) else DevAssets.assetHandler(_: String)
lazy val atHandler: String => Action[AnyContent] = if (Play.isProd) assetHandler(_: String) else DevAssets.assetHandler(_: String)

def at(file: String): Action[AnyContent] = atHandler(file)

def at(file: String): Action[AnyContent] = {
atHandler(file)
}

}

object DevAssets extends Controller {
// paths to the grunt compile directory or else the application directory, in order of importance
val runtimeDirs = Play.configuration.getStringList("yeoman.devDirs")
val basePaths: List[java.io.File] = runtimeDirs match {
case Some(dirs) => dirs.map(Play.application.getFile _).toList
case Some(dirs) => dirs.asScala.map(Play.application.getFile _).toList
case None => List(Play.application.getFile("ui/.tmp"), Play.application.getFile("ui/app"))
}

Expand All @@ -72,9 +62,11 @@ object DevAssets extends Controller {

// take the files that exist and generate the response that they would return
val responses = targetPaths filter {
_.exists()
file =>
file.exists()
} map {
Ok.sendFile(_, inline = true).withHeaders(CACHE_CONTROL -> "no-store")
file =>
Ok.sendFile(file, inline = true).withHeaders(CACHE_CONTROL -> "no-store")
}

// return the first valid path, return NotFound if no valid path exists
Expand Down
13 changes: 8 additions & 5 deletions play-yeoman/project/Build.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import sbt._
import Keys._
import play.Project._
import play.Play.autoImport._
import PlayKeys._

object ApplicationBuild extends Build {

val appName = "play-yeoman"
val appVersion = "0.6.4"
val appVersion = "0.7.1"

val appDependencies = Seq(
// Add your project dependencies here,
//jdbc,
//anorm
)


val main = play.Project(appName, appVersion, appDependencies).settings(
val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings(
version := appVersion,
libraryDependencies ++= appDependencies,
// Add your own project settings here
scalaVersion in Global := "2.10.2",
scalaVersion in Global := "2.10.4",
crossScalaVersions := Seq("2.10.4", "2.11.1"),
homepage := Some(url("https://github.com/tuplejump/play-yeoman")),
organization := "com.tuplejump",
organizationName := "Tuplejump Software PVt. Ltd.",
Expand Down
2 changes: 1 addition & 1 deletion play-yeoman/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.0
sbt.version=0.13.5
2 changes: 1 addition & 1 deletion play-yeoman/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ logLevel := Level.Warn
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.0")

Loading

0 comments on commit 588e6ba

Please sign in to comment.