Permalink
Browse files

Update to support development independent of client projects.

  • Loading branch information...
daithiocrualaoich committed Apr 12, 2012
1 parent c4a087f commit e87c956a4e4ef916b2736702cf33595579b94541
Showing with 63 additions and 50 deletions.
  1. +4 −1 .gitignore
  2. +3 −2 build.sbt
  3. BIN dev/sbt-launch-0.11.2.jar
  4. +2 −2 project/plugins.sbt
  5. +17 −0 sbt011
  6. +37 −45 src/main/scala/frontend/Frontend.scala
View
@@ -1,2 +1,5 @@
.idea*
-target/
+.cache
+.classpath
+.project
+target/
View
@@ -13,11 +13,12 @@ resolvers ++= Seq(
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
)
+seq(scalariformSettings: _*)
+
+
//adding plugin here as we want it to propagate to projects that use this plugin
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.7.3")
addSbtPlugin("play" % "sbt-plugin" % "2.0")
addSbtPlugin("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.3.1")
-
-
View
Binary file not shown.
View
@@ -5,6 +5,6 @@ resolvers ++= Seq(
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")
+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")
-
-
+addSbtPlugin("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.3.1")
View
17 sbt011
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# SBT configuration
+export SBT_BOOT_DIR=${HOME}/.sbt/boot/
+
+if [ ! -d "${SBT_BOOT_DIR}" ]; then
+ mkdir -p ${SBT_BOOT_DIR}
+fi
+
+if [ -f "~/.sbtconfig" ]; then
+ . ~/.sbtconfig
+fi
+
+java -Xmx768M -XX:MaxPermSize=384m \
+ -Dhttp.proxyHost=devscreen.gudev.gnl -Dhttp.proxyPort=3128 \
+ -Dsbt.boot.directory=$SBT_BOOT_DIR \
+ -jar `dirname $0`/dev/sbt-launch-0.11.2.jar "$@"
@@ -9,9 +9,7 @@ import AssemblyKeys._
import PlayProject._
import com.typesafe.sbtscalariform.ScalariformPlugin
-
-object Frontend extends Plugin
-{
+object Frontend extends Plugin {
val LessFile = """(.*)\.less$""".r
val CoffeeFile = """(.*)\.coffee$""".r
val JavaScriptFile = """(.*)\.js$""".r
@@ -25,7 +23,8 @@ object Frontend extends Plugin
private def digestFor(file: File): String = Hash.toHex(Files.getDigest(file, MessageDigest.getInstance("MD5")))
- private def staticFileRoutes = (baseDirectory , streams, sourceManaged).map { (base, s, sourceDir) => {
+ private def staticFileRoutes = (baseDirectory, streams, sourceManaged).map { (base, s, sourceDir) =>
+ {
val staticMap = hashFiles(base).map {
case (raw, cached) => """ "%s" -> "%s" """ format (raw, cached)
} mkString (",")
@@ -34,35 +33,27 @@ object Frontend extends Plugin
package controllers
object Static {
-
lazy val staticMappings = Map[String, String](
%s
)
lazy val reverseMappings = staticMappings.map{ _.swap }
def at(path: String, file: String) = Assets.at(path, reverseMappings(file))
-
def at(path: String) = "/assets/" + staticMappings(path)
-
}
""" format (staticMap)
-
val file = sourceDir / "controllers" / "Static.scala"
IO.write(file, template)
Seq(file)
-
}
}
- def hashFiles(base: File): Seq[(String,String)] = {
-
+ def hashFiles(base: File): Seq[(String, String)] = {
val assetsDir = (base / "app" / "assets")
-
val resourceFiles = (assetsDir ** "*").get.filter(!_.isDirectory)
-
val hashedResourceFiles = resourceFiles.flatMap(f => f.relativeTo(assetsDir).map((digestFor(f), _)))
val generatedPaths = hashedResourceFiles flatMap {
@@ -95,48 +86,49 @@ object Frontend extends Plugin
def buildDeployArtifact =
(assembly, streams, baseDirectory, target, resourceManaged in Compile, name) map {
- (jar, s, baseDir, outDir, resourcesDir, projectName) => {
- val log = s.log
+ (jar, s, baseDir, outDir, resourcesDir, projectName) =>
+ {
+ val log = s.log
- val distFile = outDir / "artifacts.zip"
- log.info("Disting %s ..." format distFile)
+ val distFile = outDir / "artifacts.zip"
+ log.info("Disting %s ..." format distFile)
- if (distFile exists) { distFile delete() }
+ if (distFile exists) { distFile delete () }
+ val cacheBustedResources = hashFiles(baseDir)
- val cacheBustedResources = hashFiles(baseDir)
+ val resourceAssetsDir = resourcesDir / "public"
+ val resourceAssets = cacheBustedResources map {
+ case (key, cachedKey) =>
+ (resourceAssetsDir / key, cachedKey)
+ } filter { fileExists }
- val resourceAssetsDir = resourcesDir / "public"
- val resourceAssets = cacheBustedResources map { case (key, cachedKey) =>
- (resourceAssetsDir / key, cachedKey)
- } filter { fileExists }
+ val publicAssetsDir = baseDir / "public"
+ val publicAssets = cacheBustedResources map {
+ case (key, cachedKey) =>
+ (publicAssetsDir / key, cachedKey)
+ } filter { fileExists }
- val publicAssetsDir = baseDir / "public"
- val publicAssets = cacheBustedResources map { case (key, cachedKey) =>
- (publicAssetsDir / key, cachedKey)
- } filter { fileExists }
+ val staticFiles = (resourceAssets ++ publicAssets) map {
+ case (file, cachedKey) =>
+ val locationInZip = "packages/%s/static-files/%s".format(projectName, cachedKey)
+ log.verbose("Static file %s -> %s" format (file, locationInZip))
+ (file, locationInZip)
+ }
+ val filesToZip = Seq(
+ baseDir / "conf" / "deploy.json" -> "deploy.json",
+ jar -> "packages/%s/%s".format(projectName, jar.getName)
+ ) ++ staticFiles
- val staticFiles = (resourceAssets ++ publicAssets) map { case (file, cachedKey) =>
- val locationInZip = "packages/%s/static-files/%s".format(projectName, cachedKey)
- log.verbose("Static file %s -> %s" format (file, locationInZip))
- (file, locationInZip)
- }
-
- val filesToZip = Seq(
- baseDir / "conf" / "deploy.json" -> "deploy.json",
- jar -> "packages/%s/%s".format(projectName, jar.getName)
- ) ++ staticFiles
+ IO.zip(filesToZip, distFile)
+ // Tells TeamCity to publish the artifact => leave this println in here
+ println("##teamcity[publishArtifacts '%s => .']" format distFile)
- IO.zip(filesToZip, distFile)
-
- //tells TeamCity to publish the artifact => leav this println in here
- println("##teamcity[publishArtifacts '%s => .']" format distFile)
-
- log.info("Done disting.")
- jar
- }
+ log.info("Done disting.")
+ jar
+ }
}
private def fileExists(f: (File, String)) = f._1.exists()

0 comments on commit e87c956

Please sign in to comment.