Skip to content

Commit

Permalink
Merge pull request #77 from tuplejump/develop
Browse files Browse the repository at this point in the history
Release 0.8.0
  • Loading branch information
Shiti committed Jun 20, 2015
2 parents 24f9dad + ee5b7d0 commit b26d1d4
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 71 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
play-yeoman
===========

[![Join the chat at https://gitter.im/tuplejump/play-yeoman](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tuplejump/play-yeoman?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

**play-yeoman** is a sbt+play plugin that brings the streamlined frontend development workflow and optimized build system of [yeoman](http://yeoman.io) to [Play 2.0](http://playframework.org).

In this approach, you would use play for developing the application backend/services and develop the frontend/ui using the yeoman toolchain, all in a totally integrated workflow and single unified console.
Expand Down Expand Up @@ -38,9 +40,14 @@ How to use it?
addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "play-compatible-version")
```
play-compatible-version = 0.7.1 for Play 2.3.0 and 0.6.4 for Play 2.2.x

Note: support for Scala 2.11 is available from version 0.7.1
The play-compatible-version depends on the version of Playframework being used,

| play framework version(s) | sbt-yeoman version | scala binary |
|---------------------------|--------------------|--------------|
| 2.2.x | 0.6.4 | 2.10 |
| 2.3.x | 0.7.1 | 2.10, 2.11 |
| 2.4.x | 0.8.0 | 2.11 |


3) Import Yeoman classes in the project build adding the following import to `project/Build.scala`,
Expand All @@ -64,7 +71,7 @@ Using 0.6.4
```


Using 0.7.1
Using >= 0.7.1

```scala
val appSettings = Seq(version := appVersion, libraryDependencies ++= appDependencies) ++
Expand Down Expand Up @@ -210,7 +217,7 @@ Using 0.6.4
```

Using 0.7.1
Using >= 0.7.1

```
val appSettings = Seq(version := appVersion, libraryDependencies ++= appDependencies) ++
Expand All @@ -228,7 +235,7 @@ Using 0.7.1

* Look at the yo-demo project for details!

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

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

Expand Down
4 changes: 4 additions & 0 deletions notes/0.7.2.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
New in this release -

* This is a minor bug fix release over [v0.7.1]
* tasks dist and stage result in an error when grunt fails if grunt force is disabled. The method dependsOn has been removed from sbt since 0.13.0. Refer [sbt issue#1001](https://github.com/sbt/sbt/issues/1001)
10 changes: 10 additions & 0 deletions notes/0.8.0.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
New in this release

+ Support Play 2.4.0
+ fixes #40 - Dependence on successful grunt build (if force is not enabled)
+ merged #60 - Grunt clean on sbt clean so we don't rely on stale templates

This release wouldn't be possible without contributions from -

+ [Trey Hyde](https://github.com/treyhyde)
+ [Konstantin Nikiforov] (https://github.com/helllamer)
13 changes: 9 additions & 4 deletions play-yeoman/project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PlayKeys._
object ApplicationBuild extends Build {

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

val appDependencies = Seq(
// Add your project dependencies here,
Expand All @@ -18,11 +18,11 @@ object ApplicationBuild extends Build {
version := appVersion,
libraryDependencies ++= appDependencies,
// Add your own project settings here
scalaVersion in Global := "2.10.4",
crossScalaVersions := Seq("2.10.4", "2.11.1"),
scalaVersion in Global := "2.11.6",
crossScalaVersions := Seq("2.11.6"),
homepage := Some(url("https://github.com/tuplejump/play-yeoman")),
organization := "com.tuplejump",
organizationName := "Tuplejump Software PVt. Ltd.",
organizationName := "Tuplejump Software Pvt. Ltd.",
organizationHomepage := Some(new java.net.URL("http://www.tuplejump.com")),
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
publishMavenStyle := true,
Expand All @@ -44,6 +44,11 @@ object ApplicationBuild extends Build {
<connection>scm:git:git@github.com:tuplejump/play-yeoman.git</connection>
</scm>
<developers>
<developer>
<id>eraoferrors</id>
<name>Shiti Saxena</name>
<url>https://twitter.com/Shiti</url>
</developer>
<developer>
<id>milliondreams</id>
<name>Rohit Rai</name>
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.5
sbt.version=0.13.8
4 changes: 2 additions & 2 deletions play-yeoman/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
// The Typesafe repository
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.3.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")

47 changes: 29 additions & 18 deletions sbt-yeoman/app/com/tuplejump/sbt/yeoman/Yeoman.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package com.tuplejump.sbt.yeoman
import sbt._
import sbt.Keys._
import java.net.InetSocketAddress
import play.Play.autoImport._
import play.sbt.Play.autoImport._
import PlayKeys._
import com.typesafe.sbt.web.Import._

import com.typesafe.sbt.packager.universal.Keys._
import com.typesafe.sbt.packager.Keys._
import play.PlayRunHook
import play.twirl.sbt.Import._

Expand All @@ -36,16 +36,11 @@ object Yeoman extends Plugin {

val forceGrunt = SettingKey[Boolean]("key to enable/disable grunt tasks with force option")

private val gruntDist = TaskKey[Unit]("Task to run dist grunt")
private val gruntDist = TaskKey[Int]("Task to run dist grunt")
private val gruntClean = TaskKey[Unit]("Task to run grunt clean")

val yeomanSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq("com.tuplejump" %% "play-yeoman" % "0.7.1" intransitive()),

// Turn off play's internal less compiler
lessEntryPoints := Nil,

// Turn off play's internal javascript compiler
javascriptEntryPoints := Nil,
libraryDependencies ++= Seq("com.tuplejump" %% "play-yeoman" % "0.8.0" intransitive()),

// Where does the UI live?
yeomanDirectory <<= (baseDirectory in Compile) {
Expand All @@ -60,20 +55,36 @@ object Yeoman extends Plugin {
val gruntFile = (yeomanGruntfile in Compile).value
//stringToProcess("grunt " + (Def.spaceDelimited("<arg>").parsed).mkString(" ")).!!,
val isForceEnabled = (forceGrunt in Compile).value
runGrunt(base, gruntFile, Def.spaceDelimited("<arg>").parsed.toList, isForceEnabled).get.exitValue()
runGrunt(base, gruntFile, Def.spaceDelimited("<arg>").parsed.toList, isForceEnabled).exitValue()
},

gruntClean := {
val base = (yeomanDirectory in Compile).value
val gruntFile = (yeomanGruntfile in Compile).value
//stringToProcess("grunt " + (Def.spaceDelimited("<arg>").parsed).mkString(" ")).!!,
val isForceEnabled = (forceGrunt in Compile).value
val result = runGrunt(base, gruntFile, List("clean") ,isForceEnabled = isForceEnabled).exitValue()
if (result == 0) {
result
} else throw new Exception("grunt failed")
},

gruntDist := {
val base = (yeomanDirectory in Compile).value
val gruntFile = (yeomanGruntfile in Compile).value
//stringToProcess("grunt " + (Def.spaceDelimited("<arg>").parsed).mkString(" ")).!!,
val isForceEnabled = (forceGrunt in Compile).value
runGrunt(base, gruntFile, isForceEnabled = isForceEnabled).get.exitValue()
val result = runGrunt(base, gruntFile, isForceEnabled = isForceEnabled).exitValue()
if (result == 0) {
result
} else throw new Exception("grunt failed")
},

dist <<= dist dependsOn (gruntDist),
dist <<= dist dependsOn gruntDist,

stage <<= stage dependsOn gruntDist,

stage <<= stage dependsOn (gruntDist),
clean <<= clean dependsOn gruntClean,

// Add the views to the dist
unmanagedResourceDirectories in Assets <+= (yeomanDirectory in Compile)(base => base / "dist"),
Expand Down Expand Up @@ -115,7 +126,7 @@ object Yeoman extends Plugin {

private def runGrunt(base: sbt.File, gruntFile: String,
args: List[String] = List.empty,
isForceEnabled: Boolean = true): Option[Process] = {
isForceEnabled: Boolean = true): Process = {
//println(s"Will run: grunt --gruntfile=$gruntFile $args in ${base.getPath}")

val arguments = if (isForceEnabled) {
Expand All @@ -131,11 +142,11 @@ object Yeoman extends Plugin {
if (System.getProperty("os.name").startsWith("Windows")) {
val process: ProcessBuilder = Process("cmd" :: "/c" :: "grunt" :: "--gruntfile=" + gruntFile :: arguments, base)
println(s"Will run: ${process.toString} in ${base.getPath}")
Option(process.run)
process.run
} else {
val process: ProcessBuilder = Process("grunt" :: "--gruntfile=" + gruntFile :: arguments, base)
println(s"Will run: ${process.toString} in ${base.getPath}")
Option(process.run)
process.run
}
}

Expand All @@ -162,7 +173,7 @@ object Yeoman extends Plugin {
var process: Option[Process] = None

override def afterStarted(addr: InetSocketAddress): Unit = {
process = runGrunt(base, gruntFile, "watch" :: Nil, isForceEnabled)
process = Some(runGrunt(base, gruntFile, "watch" :: Nil, isForceEnabled))
}

override def afterStopped(): Unit = {
Expand Down
17 changes: 9 additions & 8 deletions sbt-yeoman/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ organization := "com.tuplejump"

sbtPlugin := true

version := "0.7.1"
version := "0.8.0"

sbtVersion in Global := "0.13.5"

scalaVersion := "2.10.4"

libraryDependencies += "org.scalatest" % "scalatest_2.10" % "1.9.1" % "test"
sbtVersion in Global := "0.13.8"

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.0.2")

licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))

Expand Down Expand Up @@ -57,6 +53,11 @@ pomExtra := (
<connection>scm:git:git@github.com:tuplejump/play-yeoman.git</connection>
</scm>
<developers>
<developer>
<id>eraoferrors</id>
<name>Shiti Saxena</name>
<url>https://twitter.com/Shiti</url>
</developer>
<developer>
<id>milliondreams</id>
<name>Rohit Rai</name>
Expand Down
6 changes: 1 addition & 5 deletions sbt-yeoman/project/build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#
#Fri May 10 17:37:41 IST 2013
template.uuid=a5227c77d39109b6550a47758c2f9a1341e06524
sbt.version=0.13.5
activator.abi.version=0.1.1
sbt.version=0.13.8
8 changes: 3 additions & 5 deletions yo-demo/project/Build.scala
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import sbt._
import Keys._
import com.tuplejump.sbt.yeoman.Yeoman
import play.Play.autoImport._
import play.sbt.Play.autoImport._
import PlayKeys._

object ApplicationBuild extends Build {

val appName = "yo-demo"
val appVersion = "1.7"
val appVersion = "2.0.0"

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

val appSettings = Seq(version := appVersion, libraryDependencies ++= appDependencies, scalaVersion := "2.11.1") ++
val appSettings = Seq(version := appVersion, libraryDependencies ++= appDependencies, scalaVersion := "2.11.6") ++
Yeoman.yeomanSettings ++
Yeoman.withTemplates

Expand Down
2 changes: 1 addition & 1 deletion yo-demo/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.5
sbt.version=0.13.8
4 changes: 2 additions & 2 deletions yo-demo/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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.3.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")

addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "0.7.1")
addSbtPlugin("com.tuplejump" % "sbt-yeoman" % "0.8.0")

2 changes: 1 addition & 1 deletion yo-demo/ui/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = function (grunt) {
],
test: {
options: {
jshintrc: 'test/.jshintrc'
jshintrc: '.jshintrc'
},
src: ['test/spec/{,*/}*.js']
}
Expand Down
3 changes: 0 additions & 3 deletions yo-demo/ui/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css({.tmp,app}) styles/main.css -->
Expand Down Expand Up @@ -54,11 +53,9 @@ <h3 class="text-muted">ui</h3>

<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="components/jquery/jquery.js"></script>
<script src="components/es5-shim/es5-shim.js"></script>
<script src="components/angular/angular.js"></script>
<script src="components/json3/lib/json3.min.js"></script>
<script src="components/bootstrap/dist/js/bootstrap.js"></script>
<script src="components/angular-resource/angular-resource.js"></script>
<script src="components/angular-cookies/angular-cookies.js"></script>
<script src="components/angular-sanitize/angular-sanitize.js"></script>
Expand Down
50 changes: 50 additions & 0 deletions yo-demo/ui/app/index2.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
</head>
<body ng-app="uiApp">
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->

<!--[if lt IE 9]>
<script src="components/es5-shim/es5-shim.js"></script>
<script src="components/json3/lib/json3.min.js"></script>
<![endif]-->

<div>Hello!</div>

<!-- Add your site or application content here -->
<div class="container" ng-view></div>

<script src="components/angular/angular.js"></script>
<script src="components/angular-resource/angular-resource.js"></script>
<script src="components/angular-cookies/angular-cookies.js"></script>
<script src="components/angular-sanitize/angular-sanitize.js"></script>

<!-- build:js scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<!-- endbuild -->

<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
</body>
</html>
Loading

0 comments on commit b26d1d4

Please sign in to comment.