Skip to content

Commit 987f50d

Browse files
authored
Merge pull request #81 from ThoughtWorksInc/cross-build-scala-js
Cross build for Scala.js 1.x and 0.6
2 parents c001b53 + a304b61 commit 987f50d

File tree

6 files changed

+50
-17
lines changed

6 files changed

+50
-17
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ before_deploy:
2929

3030
deploy:
3131
- provider: script
32-
script: sbt ++$TRAVIS_SCALA_VERSION "set every Seq(sonatypeSessionName := \"Travis Job $TRAVIS_JOB_NAME $TRAVIS_JOB_NUMBER ($TRAVIS_JOB_WEB_URL)\", publishTo := sonatypePublishToBundle.value)" publishSigned sonatypeBundleRelease
32+
script: sbt $SBT_ARGS ++$TRAVIS_SCALA_VERSION "set every Seq(sonatypeSessionName := \"Travis Job $TRAVIS_JOB_NAME $TRAVIS_JOB_NUMBER ($TRAVIS_JOB_WEB_URL)\", publishTo := sonatypePublishToBundle.value)" publishSigned sonatypeBundleRelease
3333
skip_cleanup: true
3434
on:
3535
all_branches: true
3636
condition: $GITHUB_PERSONAL_ACCESS_TOKEN
37+
38+
env:
39+
- SBT_ARGS=
40+
- SBT_ARGS=--addPluginSbtFile=project/plugins.sbt.scalajs06
41+
42+
sbt_args: $SBT_ARGS

build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
2+
13
Global / parallelExecution := false
24

35
publish / skip := true
46

57
organization in ThisBuild := "com.thoughtworks.binding"
68

7-
lazy val bindable = crossProject in file(".")
8-
lazy val bindableJVM = bindable.jvm
9-
lazy val bindableJS = bindable.js
9+
lazy val bindable = crossProject(JVMPlatform, JSPlatform) in file(".")

js/js.sbt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
enablePlugins(ScalaJSBundlerPlugin)
2+
13
enablePlugins(Example)
24

3-
libraryDependencies += "com.thoughtworks.binding" %%% "jspromisebinding" % "12.0.0-M0"
5+
libraryDependencies += "com.thoughtworks.binding" %%% "jspromisebinding" % "12.0.0-M1"
46

57
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
68

7-
jsDependencies in Test += RuntimeDOM
8-
9-
inConfig(Test) {
10-
jsEnv := RhinoJSEnv().value
11-
}
9+
requireJsDomEnv in Test := true

project/plugins.sbt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
88

99
addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2")
1010

11-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.32")
11+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1")
12+
13+
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
14+
15+
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0")
1216

1317
addSbtPlugin("com.thoughtworks.sbt-scala-js-map" % "sbt-scala-js-map" % "4.0.0")
1418

project/plugins.sbt.scalajs06

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// An optional sbt file to replace Scala.js 1.0 with 0.6
2+
dependencyOverrides += Defaults.sbtPluginExtra(
3+
"org.scala-js" % "sbt-scalajs" % "0.6.32",
4+
sbtBinaryVersion.value,
5+
scalaBinaryVersion.value,
6+
)
7+
8+
dependencyOverrides += Defaults.sbtPluginExtra(
9+
"ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0-0.6",
10+
sbtBinaryVersion.value,
11+
scalaBinaryVersion.value,
12+
)
13+
14+
Compile / sourceGenerators += Def.task {
15+
val file = (Compile / sourceManaged).value / "SkipPublishForNonScalaJSProjects.scala"
16+
IO.write(file, """
17+
import scalajscrossproject.ScalaJSCrossPlugin.autoImport._
18+
import sbtcrossproject.CrossPlugin.autoImport._
19+
import sbt._, Keys._
20+
object SkipPublishForNonScalaJSProjects extends AutoPlugin {
21+
override def trigger = allRequirements
22+
override def projectSettings = Seq(
23+
publish / skip := crossProjectPlatform.value != JSPlatform
24+
)
25+
}
26+
""")
27+
Seq(file)
28+
}.taskValue

shared/build.sbt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.1.1" % Test
22

3-
libraryDependencies += "com.thoughtworks.binding" %%% "binding" % "12.0.0-M0"
4-
5-
libraryDependencies += "com.thoughtworks.binding" %%% "futurebinding" % "12.0.0-M0"
6-
7-
libraryDependencies += "com.thoughtworks.binding" %%% "futurebinding" % "12.0.0-M0"
3+
libraryDependencies += "com.thoughtworks.binding" %%% "binding" % "12.0.0-M1"
84

5+
libraryDependencies += "com.thoughtworks.binding" %%% "futurebinding" % "12.0.0-M1"
96

107
libraryDependencies += "org.typelevel" %% "simulacrum" % "1.0.0"
118

129
libraryDependencies += "com.thoughtworks.enableIf" %% "enableif" % "1.1.7"
1310

14-
scalacOptions += "-Ymacro-annotations"
11+
scalacOptions += "-Ymacro-annotations"

0 commit comments

Comments
 (0)