Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use scala.js from maven

Tags:

maven

scala.js

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.

like image 495
Konstantin Solomatov Avatar asked Oct 22 '14 16:10

Konstantin Solomatov


2 Answers

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

like image 198
Andrei Pozolotin Avatar answered Oct 19 '22 02:10

Andrei Pozolotin


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.

like image 26
sjrd Avatar answered Oct 19 '22 00:10

sjrd