-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
92 lines (76 loc) · 2.86 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name := """ksql-web"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.12.4"
scalacOptions ++= Seq("-feature", "-deprecation")
libraryDependencies += guice
libraryDependencies += ws
libraryDependencies += "org.webjars" % "codemirror" % "5.33.0"
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
watchSources := watchSources.value.filter { _.getName.endsWith(".scala") }
// Adds additional packages into Twirl
//TwirlKeys.templateImports += "com.connexity.plm.controllers._"
// Adds additional packages into conf/routes
// play.sbt.routes.RoutesKeys.routesImport += "com.connexity.plm.binders._"
val elmMake = taskKey[Seq[File]]("elm-make")
elmMake := {
import com.typesafe.sbt.web.LineBasedProblem
import play.sbt.PlayExceptions.CompilationException
val debugFlag: String =
if (sys.props.getOrElse("elm.debug", "false").toLowerCase != "true") ""
else "--debug"
var outErrLines: List[String] = Nil
var srcFilePath: Option[String] = None
var lineNum: Option[String] = None
var offset: Option[String] = None
Seq(
"bash", "-c",
"elm-make " +
(file("app/assets/javascripts") ** "*.elm").get.mkString(" ") +
" --output public/javascripts/main.js " +
s"--yes ${debugFlag} --warn"
).!(
new ProcessLogger {
override def info(s: => String): Unit = {
streams.value.log.info(s)
outErrLines = s :: outErrLines
}
override def error(s: => String): Unit = {
streams.value.log.warn(s)
val SrcFilePathExtractor = """-- [A-Z ]+ -+ (app/assets/javascripts/.+\.elm)""".r
val LineNumExtractor = """([0-9]+)\|.*""".r
val PosExtractor = """ *\^+ *""".r
s match {
case SrcFilePathExtractor(path: String) =>
srcFilePath = srcFilePath orElse Some(path)
case LineNumExtractor(num: String) =>
lineNum = lineNum orElse Some(num)
case PosExtractor() =>
offset = offset orElse Some(s)
case _ =>
}
outErrLines = s :: outErrLines
}
override def buffer[T](f: => T): T = f
}
) match {
case 0 =>
streams.value.log.success("elm-make completed.")
Seq(file("public/javascripts/main.js"))
case 127 =>
streams.value.log.warn("elm-make not found in PATH. Skipping Elm build.")
Nil
case _ =>
throw CompilationException(
new LineBasedProblem(
message = outErrLines.reverse.mkString("\n"),
severity = null,
lineNumber = lineNum.map(_.toInt).getOrElse(0),
characterOffset = offset.map(_.indexOf('^') - 2 - lineNum.map(_.length).getOrElse(0)).getOrElse(0),
lineContent = "",
source = file(srcFilePath.getOrElse("app/assets/javascripts/Main.elm"))
)
)
}
}
sourceGenerators in Assets += elmMake.taskValue