aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2015-03-21 13:02:13 +0100
committerJakob Odersky <jodersky@gmail.com>2015-03-21 13:58:48 +0100
commit68506291fb99108fd0d9305cff28dba4cd0a51f2 (patch)
treeb7d09c4fbf86c759dcba0073d1a1be1fb7b8bb99
parent5b81969b7bad3d16e3dfce2820e5ee0074909688 (diff)
downloadmavigator-68506291fb99108fd0d9305cff28dba4cd0a51f2.tar.gz
mavigator-68506291fb99108fd0d9305cff28dba4cd0a51f2.tar.bz2
mavigator-68506291fb99108fd0d9305cff28dba4cd0a51f2.zip
Use vmunier's sbt-play-scalajs plugin. Fixes #7.
-rw-r--r--README.md21
-rw-r--r--project/Build.scala32
-rw-r--r--project/plugins.sbt4
-rw-r--r--project/util.scala29
-rw-r--r--vfd-main/app/views/main.scala.html9
5 files changed, 46 insertions, 49 deletions
diff --git a/README.md b/README.md
index 964f3c9..e953639 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Virtual Flight Deck for UAVs
+b# Virtual Flight Deck for UAVs
Web interface simulating a cockpit of an unmanned aerial vehicle, built with Akka, Play and ScalaJS.
@@ -8,19 +8,16 @@ This project is made of several subprojects:
- `vfd-uav` communication backend for message exchange with drones
# Run
-SBT is used as the build tool. However, the standard 'sbt run' procedure does not work as there seems
-to be some problems with plugins used.
-Hence, the general workflow is as follows:
+SBT is used as the build tool. To get started:
1. start sbt in the base directory
- 2. enter 'project vfd-main'
- 3. enter 'run'
- *Note: if this is the first time your run a play project throught sbt, be aware that you may need to wait a while as your computer downloads half the internet*
- 4. open localhost:9000 in a modern browser to see the application in action
- 5. make some changes
- 6. go to step 4 (the application is automatically recompiled)
-
-Currently, standalone deployment and packaging of the application is not is broken.
+ 2. enter 'run'
+ *Note: if this is the first time your run a play project through sbt, be aware that you may need to wait a while as your computer downloads half the internet*
+ 3. open localhost:9000 in a modern browser to see the application in action
+ 4. make some changes
+ 5. go to step 3 (the application is automatically recompiled)
+
+The application can be deployed as a standalone package by running the 'dist' task.
# Developer Overview
The general idea of this project is to create a web interface for displaying live data from a drone.
diff --git a/project/Build.scala b/project/Build.scala
index c2eaabe..60a3edc 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -1,14 +1,21 @@
import sbt._
import sbt.Keys._
-import util._
+import sbt.Project.projectToRef
+
import play._
import play.PlayImport.PlayKeys._
+
import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import com.github.jodersky.mavlink.sbt._
import com.github.jodersky.mavlink.sbt.MavlinkKeys._
+import playscalajs.ScalaJSPlay
+import playscalajs.PlayScalaJS.autoImport._
+import com.typesafe.sbt.web.Import._
+
+
object ApplicationBuild extends Build {
//settings common to all projects
@@ -18,12 +25,20 @@ object ApplicationBuild extends Build {
mavlinkDialect := (baseDirectory in ThisBuild).value / "mavlink" / "concise.xml"
)
- lazy val root = Project("root", file(".")).aggregate(
- main,
- uav,
- dashboard
+ //root super-project
+ lazy val root = (
+ Project("root", file(".")).aggregate(
+ main,
+ uav,
+ dashboard
+ )
+ settings(
+ //goto main project on load
+ onLoad in Global := (Command.process("project vfd-main", _: State)) compose (onLoad in Global).value
+ )
)
+ //main play project
lazy val main = (
Project("vfd-main", file("vfd-main"))
enablePlugins(PlayScala)
@@ -31,6 +46,8 @@ object ApplicationBuild extends Build {
settings(common: _*)
settings(
resolvers += Resolver.url("scala-js-releases", url("http://dl.bintray.com/content/scala-js/scala-js-releases"))(Resolver.ivyStylePatterns),
+ scalaJSProjects := Seq(dashboard),
+ pipelineStages := Seq(scalaJSProd),
libraryDependencies ++= Seq(
"org.webjars" % "bootstrap" % "3.3.1",
"org.webjars" % "font-awesome" % "4.2.0",
@@ -38,9 +55,10 @@ object ApplicationBuild extends Build {
)
)
dependsOn(uav)
- dependsOnJs(dashboard)
+ aggregate(projectToRef(dashboard))
)
+ //communication backend
lazy val uav = (
Project("vfd-uav", file("vfd-uav"))
enablePlugins(SbtMavlink)
@@ -54,9 +72,11 @@ object ApplicationBuild extends Build {
)
)
+ //web frontend
lazy val dashboard = (
Project("vfd-dashboard", file("vfd-dashboard"))
enablePlugins(ScalaJSPlugin)
+ enablePlugins(ScalaJSPlay)
enablePlugins(SbtMavlink)
settings(common: _*)
settings(
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 28d80ce..dd05065 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -1,7 +1,9 @@
-//resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/",
+resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.2")
+addSbtPlugin("com.vmunier" % "sbt-play-scalajs" % "0.2.3")
+
addSbtPlugin("com.github.jodersky" % "sbt-mavlink" % "0.1") \ No newline at end of file
diff --git a/project/util.scala b/project/util.scala
deleted file mode 100644
index 4df9127..0000000
--- a/project/util.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-import sbt._
-import sbt.Keys._
-import play._
-import play.PlayImport.PlayKeys._
-import org.scalajs.sbtplugin.ScalaJSPlugin
-import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
-import com.typesafe.sbt.packager.universal.UniversalKeys
-
-package object util extends UniversalKeys {
-
- implicit class ScalaJSPlayProject(val scalajvm: Project) {
-
- val jsOutputDir = settingKey[File]("Directory for javascript files")
-
- def dependsOnJs(scalajs: Project): Project = scalajvm.settings(
- jsOutputDir := (classDirectory in Compile).value / "public" / "lib",
- compile in Compile <<= (compile in Compile) dependsOn (fastOptJS in (scalajs, Compile)),
- dist <<= dist dependsOn (fullOptJS in (scalajs, Compile)),
- stage <<= stage dependsOn (fullOptJS in (scalajs, Compile)),
- playMonitoredFiles += (scalaSource in (scalajs, Compile)).value.getCanonicalPath
- ).settings(
- Seq(packageScalaJSLauncher, fastOptJS, fullOptJS) map { packageJSKey =>
- crossTarget in (scalajs, Compile, packageJSKey) := jsOutputDir.value
- }: _*
- )
-
- }
-
-} \ No newline at end of file
diff --git a/vfd-main/app/views/main.scala.html b/vfd-main/app/views/main.scala.html
index 42f3999..4c680fd 100644
--- a/vfd-main/app/views/main.scala.html
+++ b/vfd-main/app/views/main.scala.html
@@ -1,5 +1,7 @@
@(title: String, info: String)(content: Html)
+@import play.api.Play
+
<!DOCTYPE html>
<html lang="en">
@@ -46,7 +48,12 @@
<script type="text/javascript" src="@routes.Assets.at("lib/jquery/jquery.js")"></script>
<script type="text/javascript" src="@routes.Assets.at("lib/bootstrap/js/bootstrap.min.js")"></script>
- <script type="text/javascript" src="@routes.Assets.at("lib/vfd-dashboard-fastopt.js")"></script>
+
+ @if(Play.isProd(Play.current)) {
+ <script type="text/javascript" src="@routes.Assets.at("vfd-dashboard-opt.js")"></script>
+ } else {
+ <script type="text/javascript" src="@routes.Assets.at("vfd-dashboard-fastopt.js")"></script>
+ }
</body>
</html> \ No newline at end of file