Skip to content

Commit

Permalink
Merge pull request #45 from ThoughtWorksInc/cross-build-scalajs
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 9d8e969 + 5f8196d commit 071f687
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,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.scala-js.0.6

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

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

publish / skip := true
Expand Down
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ addSbtPlugin("com.thoughtworks.sbt-best-practice" % "sbt-best-practice" % "7.2.0

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

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("org.xerial.sbt" % "sbt-sonatype" % "3.8")

Expand Down
22 changes: 22 additions & 0 deletions project/plugins.sbt.scala-js.0.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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,
)

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

0 comments on commit 071f687

Please sign in to comment.