Skip to content

Commit

Permalink
Merge pull request #81 from ThoughtWorksInc/cross-build-scala-js
Browse files Browse the repository at this point in the history
Cross build for Scala.js 1.x and 0.6
  • Loading branch information
Atry authored Apr 19, 2020
2 parents c001b53 + a304b61 commit 987f50d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 17 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ before_deploy:

deploy:
- provider: script
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
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
skip_cleanup: true
on:
all_branches: true
condition: $GITHUB_PERSONAL_ACCESS_TOKEN

env:
- SBT_ARGS=
- SBT_ARGS=--addPluginSbtFile=project/plugins.sbt.scalajs06

sbt_args: $SBT_ARGS
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

Global / parallelExecution := false

publish / skip := true

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

lazy val bindable = crossProject in file(".")
lazy val bindableJVM = bindable.jvm
lazy val bindableJS = bindable.js
lazy val bindable = crossProject(JVMPlatform, JSPlatform) in file(".")
10 changes: 4 additions & 6 deletions js/js.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
enablePlugins(ScalaJSBundlerPlugin)

enablePlugins(Example)

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

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

jsDependencies in Test += RuntimeDOM

inConfig(Test) {
jsEnv := RhinoJSEnv().value
}
requireJsDomEnv in Test := true
6 changes: 5 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")

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

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.32")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")

addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0")

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

Expand Down
28 changes: 28 additions & 0 deletions project/plugins.sbt.scalajs06
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// An optional sbt file to replace Scala.js 1.0 with 0.6
dependencyOverrides += Defaults.sbtPluginExtra(
"org.scala-js" % "sbt-scalajs" % "0.6.32",
sbtBinaryVersion.value,
scalaBinaryVersion.value,
)

dependencyOverrides += Defaults.sbtPluginExtra(
"ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0-0.6",
sbtBinaryVersion.value,
scalaBinaryVersion.value,
)

Compile / sourceGenerators += Def.task {
val file = (Compile / sourceManaged).value / "SkipPublishForNonScalaJSProjects.scala"
IO.write(file, """
import scalajscrossproject.ScalaJSCrossPlugin.autoImport._
import sbtcrossproject.CrossPlugin.autoImport._
import sbt._, Keys._
object SkipPublishForNonScalaJSProjects extends AutoPlugin {
override def trigger = allRequirements
override def projectSettings = Seq(
publish / skip := crossProjectPlatform.value != JSPlatform
)
}
""")
Seq(file)
}.taskValue
9 changes: 3 additions & 6 deletions shared/build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.1.1" % Test

libraryDependencies += "com.thoughtworks.binding" %%% "binding" % "12.0.0-M0"

libraryDependencies += "com.thoughtworks.binding" %%% "futurebinding" % "12.0.0-M0"

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

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

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

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

scalacOptions += "-Ymacro-annotations"
scalacOptions += "-Ymacro-annotations"

0 comments on commit 987f50d

Please sign in to comment.