From 978b4f281faac5de8e3a2515dd3e2bee045ce713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Raddum=20Berg?= Date: Wed, 14 Feb 2018 20:23:10 +0100 Subject: [PATCH] #25: Port to Scala.js --- .gitignore | 2 ++ build.sbt | 17 ++++++++++++----- project/plugins.sbt | 3 +++ .../src}/main/scala/debox/Buffer.scala | 0 {src => shared/src}/main/scala/debox/Map.scala | 0 {src => shared/src}/main/scala/debox/Set.scala | 0 {src => shared/src}/main/scala/debox/Util.scala | 0 .../src}/test/scala/debox/BufferCheck.scala | 0 .../src}/test/scala/debox/MapCheck.scala | 0 .../src}/test/scala/debox/SetCheck.scala | 0 10 files changed, 17 insertions(+), 5 deletions(-) rename {src => shared/src}/main/scala/debox/Buffer.scala (100%) rename {src => shared/src}/main/scala/debox/Map.scala (100%) rename {src => shared/src}/main/scala/debox/Set.scala (100%) rename {src => shared/src}/main/scala/debox/Util.scala (100%) rename {src => shared/src}/test/scala/debox/BufferCheck.scala (100%) rename {src => shared/src}/test/scala/debox/MapCheck.scala (100%) rename {src => shared/src}/test/scala/debox/SetCheck.scala (100%) diff --git a/.gitignore b/.gitignore index 83e9768..7794124 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ TAGS *~ .#* .lib +.idea/ +target/ \ No newline at end of file diff --git a/build.sbt b/build.sbt index 1230f03..7a0825d 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,8 @@ import ReleaseTransformations._ +// shadow sbt-scalajs' crossProject and CrossType until Scala.js 1.0.0 is released +import sbtcrossproject.{crossProject, CrossType} + lazy val scalac: Seq[String] = Seq( "-deprecation", // Emit warning and location for usages of deprecated APIs. "-encoding", "utf-8", // Specify character encoding used by source files. @@ -69,9 +72,9 @@ lazy val deboxSettings = Seq( resolvers += Resolver.sonatypeRepo("releases"), libraryDependencies ++= Seq( - "org.typelevel" %% "spire" % "0.14.1", - "org.scalatest" %% "scalatest" % "3.0.4" % "test", - "org.scalacheck" %% "scalacheck" % "1.13.5" % "test" + "org.typelevel" %%% "spire" % "0.14.1", + "org.scalatest" %%% "scalatest" % "3.0.4" % "test", + "org.scalacheck" %%% "scalacheck" % "1.13.5" % "test" ), @@ -139,12 +142,16 @@ lazy val noPublishSettings = Seq( publishArtifact := false ) -lazy val core = project +lazy val core = crossProject(JSPlatform, JVMPlatform) .in(file(".")) .settings(moduleName := "debox") .settings(deboxSettings) -lazy val benchmark = project.dependsOn(core) +lazy val coreJvm = core.jvm +lazy val coreJs = core.js + +lazy val benchmark = project + .dependsOn(coreJvm) .in(file("benchmark")) .settings(moduleName := "debox-benchmark") .settings(deboxSettings) diff --git a/project/plugins.sbt b/project/plugins.sbt index ac37d4e..a3c6aca 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,3 +2,6 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.2") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22") +addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "0.3.1") // (1) +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.3.1") // (2) diff --git a/src/main/scala/debox/Buffer.scala b/shared/src/main/scala/debox/Buffer.scala similarity index 100% rename from src/main/scala/debox/Buffer.scala rename to shared/src/main/scala/debox/Buffer.scala diff --git a/src/main/scala/debox/Map.scala b/shared/src/main/scala/debox/Map.scala similarity index 100% rename from src/main/scala/debox/Map.scala rename to shared/src/main/scala/debox/Map.scala diff --git a/src/main/scala/debox/Set.scala b/shared/src/main/scala/debox/Set.scala similarity index 100% rename from src/main/scala/debox/Set.scala rename to shared/src/main/scala/debox/Set.scala diff --git a/src/main/scala/debox/Util.scala b/shared/src/main/scala/debox/Util.scala similarity index 100% rename from src/main/scala/debox/Util.scala rename to shared/src/main/scala/debox/Util.scala diff --git a/src/test/scala/debox/BufferCheck.scala b/shared/src/test/scala/debox/BufferCheck.scala similarity index 100% rename from src/test/scala/debox/BufferCheck.scala rename to shared/src/test/scala/debox/BufferCheck.scala diff --git a/src/test/scala/debox/MapCheck.scala b/shared/src/test/scala/debox/MapCheck.scala similarity index 100% rename from src/test/scala/debox/MapCheck.scala rename to shared/src/test/scala/debox/MapCheck.scala diff --git a/src/test/scala/debox/SetCheck.scala b/shared/src/test/scala/debox/SetCheck.scala similarity index 100% rename from src/test/scala/debox/SetCheck.scala rename to shared/src/test/scala/debox/SetCheck.scala