summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-11-07 16:04:19 -0800
committerJakob Odersky <jakob@odersky.com>2016-11-07 16:04:19 -0800
commita11c7826f2ba4ae20a0ab4e004e53ba910157bc3 (patch)
treed805929b057edb4671da1c36fca925b5217e1ec9
parentf71ceda12b68802de61bd0dedfbcee0ac104128b (diff)
downloadworkbench-a11c7826f2ba4ae20a0ab4e004e53ba910157bc3.tar.gz
workbench-a11c7826f2ba4ae20a0ab4e004e53ba910157bc3.tar.bz2
workbench-a11c7826f2ba4ae20a0ab4e004e53ba910157bc3.zip
Upgrade sbt and refactor to AutoPlugin
-rw-r--r--build.sbt12
-rw-r--r--project/build.properties1
-rw-r--r--src/main/scala/workbench/Plugin.scala44
3 files changed, 33 insertions, 24 deletions
diff --git a/build.sbt b/build.sbt
index 6fe54d2..985fb85 100644
--- a/build.sbt
+++ b/build.sbt
@@ -3,13 +3,13 @@ import sbt.Keys._
val scalaJsVersion = "0.6.2"
val defaultSettings = Seq(
- unmanagedSourceDirectories in Compile <+= baseDirectory(_ / "shared" / "main" / "scala"),
- unmanagedSourceDirectories in Test <+= baseDirectory(_ / "shared" / "test" / "scala")
+ unmanagedSourceDirectories in Compile += baseDirectory.value / "shared" / "main" / "scala",
+ unmanagedSourceDirectories in Test += baseDirectory.value / "shared" / "test" / "scala"
)
lazy val root = project.in(file(".")).settings(defaultSettings:_*).settings(
name := "workbench",
- version := "0.2.3",
+ version := "0.3.0-SNAPSHOT",
organization := "com.lihaoyi",
scalaVersion := "2.10.5",
sbtPlugin := true,
@@ -41,8 +41,8 @@ lazy val root = project.in(file(".")).settings(defaultSettings:_*).settings(
},
resolvers += Resolver.url("scala-js-releases",
url("http://dl.bintray.com/content/scala-js/scala-js-releases"))(
- Resolver.ivyStylePatterns),
- addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJsVersion),
+ Resolver.ivyStylePatterns),
+ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.1"),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"io.spray" % "spray-can" % "1.3.1",
@@ -58,7 +58,7 @@ lazy val root = project.in(file(".")).settings(defaultSettings:_*).settings(
lazy val client = project.in(file("client")).enablePlugins(ScalaJSPlugin)
.settings(defaultSettings: _*)
.settings(
- unmanagedSourceDirectories in Compile <+= baseDirectory(_ / ".." / "shared" / "main" / "scala"),
+ unmanagedSourceDirectories in Compile += baseDirectory.value / ".." / "shared" / "main" / "scala",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.8.0",
"com.lihaoyi" %%% "autowire" % "0.2.4",
diff --git a/project/build.properties b/project/build.properties
new file mode 100644
index 0000000..5f32afe
--- /dev/null
+++ b/project/build.properties
@@ -0,0 +1 @@
+sbt.version=0.13.13 \ No newline at end of file
diff --git a/src/main/scala/workbench/Plugin.scala b/src/main/scala/workbench/Plugin.scala
index 4c6fb9d..a120d0f 100644
--- a/src/main/scala/workbench/Plugin.scala
+++ b/src/main/scala/workbench/Plugin.scala
@@ -3,27 +3,32 @@ import scala.concurrent.ExecutionContext.Implicits.global
import sbt._
import sbt.Keys._
import autowire._
-import org.scalajs.sbtplugin.ScalaJSPlugin.AutoImport
+import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.core.tools.io._
import org.scalajs.core.tools.optimizer.ScalaJSOptimizer
import org.scalajs.sbtplugin.ScalaJSPluginInternal._
import org.scalajs.sbtplugin.Implicits._
-import AutoImport._
-object Plugin extends sbt.Plugin {
+object Plugin extends AutoPlugin {
- val refreshBrowsers = taskKey[Unit]("Sends a message to all connected web pages asking them to refresh the page")
- val updateBrowsers = taskKey[Unit]("Partially resets some of the stuff in the browser")
- val spliceBrowsers = taskKey[Unit]("Attempts to do a live update of the code running in the browser while maintaining state")
- val localUrl = settingKey[(String, Int)]("localUrl")
- private[this] val server = settingKey[Server]("local websocket server")
+ override def requires = ScalaJSPlugin
+ object autoImport {
+ val refreshBrowsers = taskKey[Unit]("Sends a message to all connected web pages asking them to refresh the page")
+ val updateBrowsers = taskKey[Unit]("Partially resets some of the stuff in the browser")
+ val spliceBrowsers = taskKey[Unit]("Attempts to do a live update of the code running in the browser while maintaining state")
+ val localUrl = settingKey[(String, Int)]("localUrl")
+ private[Plugin] val server = settingKey[Server]("local websocket server")
- val bootSnippet = settingKey[String]("piece of javascript to make things happen")
- val updatedJS = taskKey[List[String]]("Provides the addresses of the JS files that have changed")
- val sjs = inputKey[Unit]("Run a command via the sjs REPL, which compiles it to Javascript and runs it in the browser")
- val replFile = taskKey[File]("The temporary file which holds the source code for the currently executing sjs REPL")
- val sjsReset = taskKey[Unit]("Reset the currently executing sjs REPL")
+
+ val bootSnippet = settingKey[String]("piece of javascript to make things happen")
+ val updatedJS = taskKey[List[String]]("Provides the addresses of the JS files that have changed")
+ val sjs = inputKey[Unit]("Run a command via the sjs REPL, which compiles it to Javascript and runs it in the browser")
+ val replFile = taskKey[File]("The temporary file which holds the source code for the currently executing sjs REPL")
+ val sjsReset = taskKey[Unit]("Reset the currently executing sjs REPL")
+ }
+ import autoImport._
+ import ScalaJSPlugin.AutoImport._
lazy val replHistory = collection.mutable.Buffer.empty[String]
@@ -43,9 +48,10 @@ object Plugin extends sbt.Plugin {
}
files
},
- updatedJS <<= (updatedJS, localUrl) map { (paths, localUrl) =>
- paths.map { path =>
- s"http://${localUrl._1}:${localUrl._2}$path"
+ updatedJS := {
+ updatedJS.value.map{ path =>
+ val url = localUrl.value
+ s"http://${url._1}:${url._2}$path"
}
},
(extraLoggers in ThisBuild) := {
@@ -109,7 +115,7 @@ object Plugin extends sbt.Plugin {
f
},
sources in Compile += replFile.value,
- sjs <<= Def.inputTaskDyn {
+ sjs := Def.inputTaskDyn {
import sbt.complete.Parsers._
val str = sbt.complete.Parsers.any.*.parsed.mkString
val newSnippet = s"""
@@ -172,9 +178,11 @@ object Plugin extends sbt.Plugin {
println("Clearing sjs REPL History")
replHistory.clear()
},
- sjsReset <<= sjsReset.triggeredBy(fastOptJS)
+ sjsReset := sjsReset.triggeredBy(fastOptJS)
))
+ override def projectSettings = workbenchSettings
+
def munge(s0: String) = {
var s = s0
s = s.replace("\nvar ScalaJS = ", "\nvar ScalaJS = ScalaJS || ")