How do you Cross Compile to Scala.JS with Gradle
Asked Answered
V

1

4

When adding Scala.JS dependencies in SBT you use %%%. E.g.

libraryDependencies += "be.doeraene" %%% "scalajs-jquery" % "0.9.0"

How is this done in the Gradle Scala plugin?

Venule answered 20/9, 2016 at 12:49 Comment(2)
Can't really write a full answer, right now, but you should use the Scala.js Gradle pluging: github.com/gtache/scalajs-gradleReinareinald
Great! thanks for this.Venule
A
2

%%% = the scala version + scalajs version. So something like:

val scalaJsDomV = "0.9.1"
libraryDependencies ++= Seq(
   "org.scala-js" %%% "scalajs-dom" % scalaJsDomV
)

would be

compile "org.scala-js:scalajs-dom_sjs0.6_2.12:0.9.1"

Or if you used the ext for multiple used versions it would be something like:

ext {
    versions = [
        js: 'sjs0.6', 
        major: '2.12', // major scala version
    ]
    versions['scala'] = versions.major + '.2'
}
dependencies {
    ...
    compile "org.scala-js:scalajs-dom_${versions.js}_${versions.major}:0.9.1"
}

Note that there is also a plugin that can help with scalajs: https://github.com/gtache/scalajs-gradle

Avera answered 10/6, 2017 at 9:35 Comment(2)
github.com/gtache/scalajs-gradle appears to be dead - the last commit was three years ago.Roundshouldered
I don't think it works, it will only compile into java class(es) instead of the intended javascript file, which is uselessHod

© 2022 - 2024 — McMap. All rights reserved.