Konstantin Solomatov
Konstantin Solomatov

Reputation: 10352

How to use scala.js from maven

Is there any way to use scala.js with Maven. I want to use scala.js in maven based project, and AFAIU, it's hard to integrate sbt with maven.

Upvotes: 7

Views: 2180

Answers (2)

Andrei Pozolotin
Andrei Pozolotin

Reputation: 937

1) scalor-maven-plugin provides scala.js support

2) global remote shared parent pom.xml with scala.js profiles

3) gist examples of maven profiles which configure scala.js library and scala.js runtime projects

Upvotes: 10

sjrd
sjrd

Reputation: 22105

Unfortunately, this is not directly possible so far, because there is no Maven plugin enabling Scala.js.

Scala.js consists a few things:

  • A compiler plugin for scalac, which can be enabled with the Maven plugin for Scala.
  • Libraries of its own: scalajs-library, and optionally scalajs-javalibex.
  • Link-time tools: these are exposed directly within the sbt plugin, although the core of it is in a separate scalajs-tools library, which could be reused by a Maven plugin for Scala.js.

As of Scala.js 0.6.0, all these things are published on Maven Central, so can be resolved by Maven. (Except the sbt plugin with the sbt-specific parts, but that's not needed.)

As long as nobody actually develops a proper Maven plugin for Scala.js, the easiest might be to invoke the Command Line Interface of Scala.js from Maven to invoke the link-time tools (scalajsld in particular). I don't know Maven, but I assume it has tasks to invoke external command-line programs in its pipeline.

Edit: Updated for Scala.js 0.6.x: artifacts are now published on Maven Central.

Upvotes: 4

Related Questions