diff options
author | Jakob Odersky <jodersky@gmail.com> | 2014-09-30 08:57:29 +0200 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2014-09-30 08:57:29 +0200 |
commit | 8ec08695eade13b053caa6bd103065a056cdf179 (patch) | |
tree | 9ce23ab688b4a469ecf40d4b1c31a848ed7dca64 /project/Build.scala | |
download | mavigator-8ec08695eade13b053caa6bd103065a056cdf179.tar.gz mavigator-8ec08695eade13b053caa6bd103065a056cdf179.tar.bz2 mavigator-8ec08695eade13b053caa6bd103065a056cdf179.zip |
initial commit
Diffstat (limited to 'project/Build.scala')
-rw-r--r-- | project/Build.scala | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/project/Build.scala b/project/Build.scala new file mode 100644 index 0000000..af78ff5 --- /dev/null +++ b/project/Build.scala @@ -0,0 +1,66 @@ +import sbt._ +import sbt.Keys._ +import play._ +import play.PlayImport.PlayKeys._ +import scala.scalajs.sbtplugin.ScalaJSPlugin +import scala.scalajs.sbtplugin.ScalaJSPlugin.ScalaJSKeys._ + + +object ApplicationBuild extends Build { + + val common = Seq( + scalaVersion := "2.11.2", + scalacOptions ++= Seq("-feature") + ) + + lazy val root = Project("root", file(".")).aggregate( + backend, + frontend + ) + + lazy val backend = ( + Project("vfd-backend", file("backend")) + enablePlugins(PlayScala) + settings(common: _*) + settings( + libraryDependencies ++= Dependencies.backend + ) + dependsOnJs(frontend) + ) + + lazy val frontend = ( + Project("vfd-frontend", file("frontend")) + settings(ScalaJSPlugin.scalaJSSettings: _*) + settings(common: _*) + settings( + libraryDependencies ++= Dependencies.frontend + ) + ) + + + + implicit class ScalaJSPlayProject(val project: Project) { + def dependsOnJs(reference: Project): Project = project.settings( + resourceGenerators in Compile += Def.task{ + val outDir: File = (resourceManaged in Compile).value / "public" / "lib" + + val optimized: Seq[File] = (fastOptJS in (reference, Compile)).value.allCode.map(_.path).map(file(_)) + + val outFiles = optimized.map(file => outDir / file.name) + + for ((opt, out) <- optimized zip outFiles) { + if (!out.exists || out.lastModified < opt.lastModified) { + IO.copyFile(opt, out, true) + val map = opt.getParentFile / (out.name + ".map") + IO.copyFile(map, outDir / map.name) + } + } + outFiles + }.taskValue, + playMonitoredFiles ++= (watchSources in reference).value.map(_.getCanonicalPath) + ) + } + + + +}
\ No newline at end of file |