summaryrefslogtreecommitdiff
path: root/build.sbt
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-01 00:56:12 -0700
committerLi Haoyi <haoyi@dropbox.com>2014-11-01 00:56:12 -0700
commit3d73267c4b3ecf3cdca54ded8dfd8a2caeeb3ca9 (patch)
tree9f1846359c784a6e4bfc4682fddc8b6c884bf811 /build.sbt
parent058e9bac2dd8166051bafa16d51f27ee5856929a (diff)
downloadhands-on-scala-js-3d73267c4b3ecf3cdca54ded8dfd8a2caeeb3ca9.tar.gz
hands-on-scala-js-3d73267c4b3ecf3cdca54ded8dfd8a2caeeb3ca9.tar.bz2
hands-on-scala-js-3d73267c4b3ecf3cdca54ded8dfd8a2caeeb3ca9.zip
works, with a compiler-plugin based architecture supporting incremental compilation
Diffstat (limited to 'build.sbt')
-rw-r--r--build.sbt54
1 files changed, 39 insertions, 15 deletions
diff --git a/build.sbt b/build.sbt
index 4ef82fa..cb6b97d 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,27 +1,35 @@
import scala.scalajs.sbtplugin.ScalaJSPlugin._
import ScalaJSKeys._
-lazy val api = project.in(file("api"))
+lazy val scalatexApi = project.in(file("scalatexApi"))
.settings(
- libraryDependencies ++= Seq(
- "com.lihaoyi" %% "utest" % "0.2.4",
- "com.scalatags" %% "scalatags" % "0.4.2",
- "org.scala-lang" % "scala-reflect" % scalaVersion.value,
- "com.lihaoyi" %% "acyclic" % "0.1.2" % "provided",
- compilerPlugin("org.scalamacros" % s"paradise" % "2.0.0" cross CrossVersion.full)
- ) ++ (
- if (scalaVersion.value startsWith "2.11.") Nil
- else Seq("org.scalamacros" %% s"quasiquotes" % "2.0.0")
- ),
- addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
- testFrameworks += new TestFramework("utest.runner.JvmFramework")
- )
+ scalaVersion := "2.11.2",
+ libraryDependencies ++= Seq(
+ "com.lihaoyi" %% "utest" % "0.2.4",
+ "com.scalatags" %% "scalatags" % "0.4.2",
+ "org.scala-lang" % "scala-reflect" % scalaVersion.value,
+ "com.lihaoyi" %% "acyclic" % "0.1.2" % "provided"
+ ),
+ addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
+ testFrameworks += new TestFramework("utest.runner.JvmFramework")
+)
+
+lazy val scalatexPlugin = Project(
+ id = "scalatexPlugin",
+ base = file("scalatexPlugin"),
+ dependencies = Seq(scalatexApi)
+) settings (
+ scalaVersion := "2.11.2",
+ libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
+ publishArtifact in Compile := false
+)
lazy val book = Project(
id = "book",
base = file("book"),
- dependencies = Seq(api)
+ dependencies = Seq(scalatexApi)
).settings(
+ scalaVersion := "2.11.2",
libraryDependencies ++= Seq(
"org.webjars" % "highlightjs" % "8.2-1",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
@@ -31,6 +39,22 @@ lazy val book = Project(
(resources in Compile) += {
(fastOptJS in (examples, Compile)).value
(artifactPath in (examples, Compile, fastOptJS)).value
+ },
+ scalacOptions in Compile ++= {
+ val jar = (Keys.`package` in (scalatexPlugin, Compile)).value
+ val addPlugin = "-Xplugin:" + jar.getAbsolutePath
+ // add plugin timestamp to compiler options to trigger recompile of
+ // main after editing the plugin. (Otherwise a 'clean' is needed.)
+ val dummy = "-Jdummy=" + jar.lastModified
+ val options = "-P:scalatex-options:" + sourceDirectory.value / "scalatex"
+ Seq(addPlugin, dummy)
+ },
+ watchSources ++= {
+ ((sourceDirectory in Compile).value / "scalatex" ** "*.scalatex").get
+ },
+ (watchSources in Test) ++= {
+ ((sourceDirectory in Test).value / "scalatex" ** "*.scalatex").get
}
)
+
lazy val examples = project.in(file("examples")) \ No newline at end of file