summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-02 16:46:59 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-02 16:46:59 -0800
commit78f7ed0303ea42fca8f4e1535ea800d12d2a80eb (patch)
tree0bded0822fcba8fdea5d6f318603ae324b70dac4 /examples
parenta33254276bd211bf33be86eeb871ddbfe36fdb47 (diff)
downloadhands-on-scala-js-78f7ed0303ea42fca8f4e1535ea800d12d2a80eb.tar.gz
hands-on-scala-js-78f7ed0303ea42fca8f4e1535ea800d12d2a80eb.tar.bz2
hands-on-scala-js-78f7ed0303ea42fca8f4e1535ea800d12d2a80eb.zip
tweaked cross-build example
Diffstat (limited to 'examples')
-rw-r--r--examples/crossBuilds/simple/build.sbt4
-rw-r--r--examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala7
-rw-r--r--examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala11
-rw-r--r--examples/crossBuilds/simple/jvm/src/main/scala/simple/Platform.scala14
-rw-r--r--examples/crossBuilds/simple/project/build.sbt1
-rw-r--r--examples/crossBuilds/simple/shared/main/scala/simple/Simple.scala9
6 files changed, 21 insertions, 25 deletions
diff --git a/examples/crossBuilds/simple/build.sbt b/examples/crossBuilds/simple/build.sbt
index df0c84b..b0ecca7 100644
--- a/examples/crossBuilds/simple/build.sbt
+++ b/examples/crossBuilds/simple/build.sbt
@@ -1,8 +1,8 @@
lazy val js = project.in(file("js")).settings(scalaJSSettings:_*).settings(
unmanagedSourceDirectories in Compile +=
- baseDirectory.value / ".." / "shared" / "main" / "scala"
+ baseDirectory.value / "shared" / "main" / "scala"
)
lazy val jvm = project.in(file("jvm")).settings(
unmanagedSourceDirectories in Compile +=
- baseDirectory.value / ".." / "shared" / "main" / "scala"
+ baseDirectory.value / "shared" / "main" / "scala"
) \ No newline at end of file
diff --git a/examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala b/examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala
new file mode 100644
index 0000000..d3b0278
--- /dev/null
+++ b/examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala
@@ -0,0 +1,7 @@
+/*shared/main/scala/simple/Simple.scala*/
+package simple
+object Simple{
+ def formatTimes(timestamps: Seq[Long]): String = {
+ timestamps.map(Platform.format).mkString("\n")
+ }
+} \ No newline at end of file
diff --git a/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala b/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
index 40f65f4..ee2f5da 100644
--- a/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
+++ b/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
@@ -1,18 +1,17 @@
-/*js/src/main/scala/simple/Platform.scala*/
+//js/src/main/scala/simple/Platform.scala
package simple
import scala.scalajs.js
object Platform extends js.JSApp{
def format(ts: Long) = {
- new js.Date(ts).toLocaleString();
+ new js.Date(ts).toLocaleString()
}
def main() = {
- println("simple.js")
val times = Seq(
System.currentTimeMillis(),
- System.currentTimeMillis() + 1000,
- System.currentTimeMillis() + 2000
+ System.currentTimeMillis() + 1000
)
- println(Simple.formatTimestamps(times))
+ println("Running on JS! " + 1.0d)
+ println(Simple.formatTimes(times))
}
} \ No newline at end of file
diff --git a/examples/crossBuilds/simple/jvm/src/main/scala/simple/Platform.scala b/examples/crossBuilds/simple/jvm/src/main/scala/simple/Platform.scala
index af70429..e8e7a65 100644
--- a/examples/crossBuilds/simple/jvm/src/main/scala/simple/Platform.scala
+++ b/examples/crossBuilds/simple/jvm/src/main/scala/simple/Platform.scala
@@ -1,23 +1,21 @@
-/*jvm/src/main/scala/simple/Platform.scala*/
+//jvm/src/main/scala/simple/Platform.scala
package simple
import java.text.SimpleDateFormat
object Platform{
def format(ts: Long) = {
- // http://docs.oracle.com/javase/7/
- // docs/api/java/text/SimpleDateFormat.html
- val fmt = "MMMM d, yyyy h:mm:ss aaa z"
+ val fmt =
+ "MMMM d, yyyy h:mm:ss aaa z"
new SimpleDateFormat(fmt).format(
new java.util.Date(ts)
)
}
def main(args: Array[String]) = {
- println("simple.jvm")
val times = Seq(
System.currentTimeMillis(),
- System.currentTimeMillis() + 1000,
- System.currentTimeMillis() + 2000
+ System.currentTimeMillis() + 1000
)
- println(Simple.formatTimestamps(times))
+ println("Running on JVM! " + 1.0d)
+ println(Simple.formatTimes(times))
}
} \ No newline at end of file
diff --git a/examples/crossBuilds/simple/project/build.sbt b/examples/crossBuilds/simple/project/build.sbt
index 5ac559a..a1dbd1d 100644
--- a/examples/crossBuilds/simple/project/build.sbt
+++ b/examples/crossBuilds/simple/project/build.sbt
@@ -1 +1,2 @@
+/*project/build.sbt*/
addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.5") \ No newline at end of file
diff --git a/examples/crossBuilds/simple/shared/main/scala/simple/Simple.scala b/examples/crossBuilds/simple/shared/main/scala/simple/Simple.scala
deleted file mode 100644
index 4e693e4..0000000
--- a/examples/crossBuilds/simple/shared/main/scala/simple/Simple.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-/*shared/main/scala/simple/Simple.scala*/
-package simple
-object Simple{
- def formatTimestamps(timestamps: Seq[Long]) = {
- timestamps.map(Platform.format)
- .mkString("\n")
- }
- }
-} \ No newline at end of file