-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
build.sbt
41 lines (31 loc) · 1.4 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := sys.props.get("scala.version").getOrElse("2.10.4")
// can't use test directory since scripted calls its script "test"
sourceDirectory in Test := baseDirectory.value / "tests"
scalaSource in Test := baseDirectory.value / "tests"
// Generate a js router so we can test it with mocha
val generateJsRouter = TaskKey[Seq[File]]("generate-js-router")
generateJsRouter := {
(runMain in Compile).toTask(" utils.JavaScriptRouterGenerator target/web/jsrouter/jsRoutes.js").value
Seq(target.value / "web" / "jsrouter" / "jsRoutes.js")
}
resourceGenerators in TestAssets <+= generateJsRouter
managedResourceDirectories in TestAssets += target.value / "web" / "jsrouter"
// We don't want source position mappers is this will make it very hard to debug
sourcePositionMappers := Nil
routesGenerator := play.routes.compiler.InjectedRoutesGenerator
compile in Compile := {
(compile in Compile).result.value match {
case Inc(inc) =>
// If there was a compilation error, dump generated routes files so we can read them
(target in routes in Compile).value.***.filter(_.isFile).get.map { file =>
println("Dumping " + file + ":")
IO.readLines(file).zipWithIndex.foreach {
case (line, index) => println("%4d".format(index + 1) + ": " + line)
}
println()
}
throw inc
case Value(v) => v
}
}