Skip to content

Commit dde8815

Browse files
author
exoego
committed
Add Scala.js cross build
1 parent 29d8cc3 commit dde8815

36 files changed

+50
-26
lines changed

.travis.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ env:
1212
# SONA_PASS
1313
- secure: "ggXFZBlzV5ek/rBaE9lrEZlAIfUrv4XDJ4OrP8daMrJxmwkXtoSbcB3z4VgqqWKzAzW89CcU1IiojzDbe/het3xEX4qxdz5Wt05/E+WOgbek528kelwMxq12XRe6xaCVfG+y8OISPgq1q3vKoO/xYGVbK3D6hSD+cjojEXyPpjAfrVSUof06aNPFPQeLX9exgu9zrxkJJm01PbTh19vQk4Ojc++oEmpF7HLD1CF1m7AlW0U2Rba+syivpj9Ray3Z9vu0TnFL06r4TiwZruwcXTLrWUqumFI0r5mhaY6SNH7bqttu+3RPIOdkUGxIeGlkDi3xopt7r2aEkhOKvjRXapW0e/CWmUo1J+NnlIumxrldi4n0iiJGVEvY4Krx/HGZe0wCVTh4vDNOllTGdFmkkxN6WoaHALgj3QNM3XLjvvUu3VcT+QNtsVIvgUDesrtos8zCKczzdhL/d4BMiIg7SFfA33S3vx8BeczLBqddrx+yLSPzfheKrHW7g76EAEyN26vE2/2/GRlMOlG8Lmu8rXBfIPsK9T/ztfE1CxaTW5EsMSrxO2+O/bvAa6DY0R79KkHf7LDI+azzP2NwYx8anM9WlMTp4EbawI/KGZRilWYtJ3Q3y5EQERsrP71W35dKqiBFMPdspS+lTS9hGtso08n7cR2MwTbRjoXVRcWfJ/I="
1414
matrix:
15-
- ADOPTOPENJDK=8
16-
- ADOPTOPENJDK=11
15+
# The empty SCALAJS_VERSION will only compile for the JVM
16+
- SCALAJS_VERSION= ADOPTOPENJDK=8
17+
- SCALAJS_VERSION=0.6.28 ADOPTOPENJDK=8
18+
- SCALAJS_VERSION=1.0.0-M8 ADOPTOPENJDK=8
19+
- SCALAJS_VERSION= ADOPTOPENJDK=11
1720

1821
before_install:
1922
# adding $HOME/.sdkman to cache would create an empty directory, which interferes with the initial installation

build.sbt

+41-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
1+
import sbtcrossproject.CrossPlugin.autoImport.{ crossProject, CrossType }
12
import ScalaModulePlugin._
23

3-
scalaModuleSettings
4-
scalaModuleSettingsJVM
5-
6-
name := "scala-collection-contrib"
7-
version := "0.1.1-SNAPSHOT"
8-
9-
crossScalaVersions in ThisBuild := Seq("2.13.0")
10-
11-
scalacOptions ++= Seq("-opt-warnings", "-language:higherKinds", "-deprecation", "-feature", "-Xfatal-warnings")
12-
scalacOptions in (Compile, doc) ++= Seq("-implicits", "-groups")
13-
14-
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s", "-a")
15-
parallelExecution in Test := false // why?
16-
17-
mimaPreviousVersion := Some("0.1.0")
18-
19-
homepage := Some(url("https://github.com/scala/scala-collection-contrib"))
20-
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0"))
21-
22-
libraryDependencies ++= Seq(
23-
"junit" % "junit" % "4.12" % Test,
24-
"com.novocode" % "junit-interface" % "0.11" % Test,
25-
"org.openjdk.jol" % "jol-core" % "0.9" % Test
26-
)
4+
lazy val root = project.in(file("."))
5+
.aggregate(`scala-collection-contribJS`, `scala-collection-contribJVM`)
6+
.settings(disablePublishing)
7+
8+
lazy val `scala-collection-contrib` = crossProject(JVMPlatform, JSPlatform)
9+
.withoutSuffixFor(JVMPlatform).in(file("."))
10+
.settings(scalaModuleSettings: _*)
11+
.jvmSettings(scalaModuleSettingsJVM)
12+
.settings(
13+
name := "scala-collection-contrib",
14+
version := "0.1.1-SNAPSHOT",
15+
16+
crossScalaVersions in ThisBuild := Seq("2.13.0"),
17+
18+
scalacOptions ++= Seq("-opt-warnings", "-language:higherKinds", "-deprecation", "-feature", "-Xfatal-warnings"),
19+
scalacOptions in (Compile, doc) ++= Seq("-implicits", "-groups"),
20+
21+
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s", "-a"),
22+
parallelExecution in Test := false, // why?
23+
24+
mimaPreviousVersion := Some("0.1.0"),
25+
26+
homepage := Some(url("https://github.com/scala/scala-collection-contrib")),
27+
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
28+
29+
libraryDependencies ++= Seq(
30+
"junit" % "junit" % "4.12" % Test,
31+
"com.novocode" % "junit-interface" % "0.11" % Test,
32+
"org.openjdk.jol" % "jol-core" % "0.9" % Test
33+
)
34+
)
35+
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
36+
.jsSettings(
37+
mimaPreviousVersion := None,
38+
// Scala.js cannot run forked tests
39+
fork in Test := false
40+
)
41+
42+
lazy val `scala-collection-contribJVM` = `scala-collection-contrib`.jvm
43+
lazy val `scala-collection-contribJS` = `scala-collection-contrib`.js

project/plugins.sbt

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
22

3+
val scalajsVersion = Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("0.6.28")
4+
35
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.0.0")
6+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalajsVersion)
7+
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")

0 commit comments

Comments
 (0)