From 3d73267c4b3ecf3cdca54ded8dfd8a2caeeb3ca9 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 1 Nov 2014 00:56:12 -0700 Subject: works, with a compiler-plugin based architecture supporting incremental compilation --- build.sbt | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) (limited to 'build.sbt') 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 -- cgit v1.2.3