summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-26 02:04:40 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-26 02:04:40 -0800
commitca124817c53d50dc81c7817d37f3c5fc08e0c565 (patch)
tree4e6fee46c864eb242c761118667f8665841492a7
parent0489a0d6c8d3beceeedb8c2f6eaad7b9387073c0 (diff)
downloadhands-on-scala-js-ca124817c53d50dc81c7817d37f3c5fc08e0c565.tar.gz
hands-on-scala-js-ca124817c53d50dc81c7817d37f3c5fc08e0c565.tar.bz2
hands-on-scala-js-ca124817c53d50dc81c7817d37f3c5fc08e0c565.zip
Single click builds for reals
-rw-r--r--book/src/main/scala/book/Main.scala8
-rw-r--r--build.sbt37
-rw-r--r--readme.md6
3 files changed, 24 insertions, 27 deletions
diff --git a/book/src/main/scala/book/Main.scala b/book/src/main/scala/book/Main.scala
index cb8ef99..4b862d0 100644
--- a/book/src/main/scala/book/Main.scala
+++ b/book/src/main/scala/book/Main.scala
@@ -19,15 +19,15 @@ object Main {
def main(args: Array[String]): Unit = {
println("Writing Book")
-
- write(Book.site, "output/index.html")
+ val outputRoot = System.getProperty("output.root") + "/"
+ write(Book.site, s"$outputRoot/index.html")
val jsFiles = Book.autoResources.filter(_.endsWith(".js")).toSet
val cssFiles = Book.autoResources.filter(_.endsWith(".css")).toSet
val miscFiles = Book.autoResources -- cssFiles -- jsFiles
for(res <- Book.manualResources ++ miscFiles) {
- copy(getClass.getResourceAsStream("/" + res), "output/" + res)
+ copy(getClass.getResourceAsStream("/" + res), outputRoot + res)
}
for((resources, dest) <- Seq(jsFiles -> "scripts.js", cssFiles -> "styles.css")) {
@@ -35,7 +35,7 @@ object Main {
io.Source.fromInputStream(getClass.getResourceAsStream("/"+res)).mkString
}
- write(blobs.mkString("\n"), "output/"+dest)
+ write(blobs.mkString("\n"), outputRoot + dest)
}
val allNames = {
diff --git a/build.sbt b/build.sbt
index 441d8d5..ba3aa84 100644
--- a/build.sbt
+++ b/build.sbt
@@ -4,28 +4,30 @@ import ScalaJSKeys._
val cloneRepos = taskKey[Unit]("Clone stuff from github")
-lazy val scalaParser = project.in(file("scalaParser")).settings(
+val sharedSettings = Seq(
scalaVersion := "2.11.4",
+ libraryDependencies += "com.lihaoyi" %% "acyclic" % "0.1.2" % "provided",
+ addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
+ autoCompilerPlugins := true
+)
+
+lazy val scalaParser = project.settings(sharedSettings:_*)
+ .settings(
libraryDependencies ++= Seq(
"com.lihaoyi" %% "utest" % "0.2.4",
- "com.lihaoyi" %% "acyclic" % "0.1.2" % "provided",
"org.parboiled" %% "parboiled" % "2.0.1"
),
- addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
testFrameworks += new TestFramework("utest.runner.JvmFramework")
)
-lazy val scalatexApi = project.in(file("scalatexApi"))
+lazy val scalatexApi = project.settings(sharedSettings:_*)
.dependsOn(scalaParser)
.settings(
- scalaVersion := "2.11.4",
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",
"org.parboiled" %% "parboiled" % "2.0.1"
),
- addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
testFrameworks += new TestFramework("utest.runner.JvmFramework")
)
@@ -33,8 +35,7 @@ lazy val scalatexPlugin = Project(
id = "scalatexPlugin",
base = file("scalatexPlugin"),
dependencies = Seq(scalatexApi)
-) settings (
- scalaVersion := "2.11.4",
+).settings(sharedSettings:_*).settings(
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value,
publishArtifact in Compile := false
)
@@ -43,16 +44,11 @@ lazy val book = Project(
id = "book",
base = file("book"),
dependencies = Seq(scalatexApi)
-).settings(
- scalaVersion := "2.11.4",
+).settings(sharedSettings:_*).settings(
libraryDependencies ++= Seq(
"org.webjars" % "highlightjs" % "8.2-1",
"org.webjars" % "pure" % "0.5.0",
"org.webjars" % "font-awesome" % "4.2.0",
- "org.webjars" % "react" % "0.11.1",
- "org.scala-lang" % "scala-reflect" % scalaVersion.value,
- "org.scala-lang" % "scala-compiler" % scalaVersion.value,
- "org.eclipse.jgit" % "org.eclipse.jgit" % "3.5.1.201410131835-r",
"com.lihaoyi" %%% "upickle" % "0.2.5"
),
(resources in Compile) += {
@@ -73,14 +69,8 @@ lazy val book = Project(
watchSources ++= {
((sourceDirectory in Compile).value / "scalatex" ** "*.scalatex").get
},
- (watchSources in Test) ++= {
- ((sourceDirectory in Test).value / "scalatex" ** "*.scalatex").get
- },
- libraryDependencies += "com.lihaoyi" %% "acyclic" % "0.1.2" % "provided",
- autoCompilerPlugins := true,
- addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
cloneRepos := {
- val localPath = crossTarget.value / "clones"
+ val localPath = target.value / "clones"
if (!localPath.isDirectory){
val paths = Seq(
"scala-js" -> "scala-js",
@@ -101,7 +91,8 @@ lazy val book = Project(
},
(run in Compile) <<= (run in Compile).dependsOn(cloneRepos),
initialize := {
- System.setProperty("clone.root", crossTarget.value.getAbsolutePath + "/clones")
+ System.setProperty("clone.root", target.value.getAbsolutePath + "/clones")
+ System.setProperty("output.root", target.value.getAbsolutePath + "/output")
}
)
diff --git a/readme.md b/readme.md
index 02f2276..7f05d10 100644
--- a/readme.md
+++ b/readme.md
@@ -7,4 +7,10 @@ To build,
```
sbt book/run
+```
+
+And look in
+
+```
+book/target/output/index.html
``` \ No newline at end of file