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.
-
Theoretically you can use it in maven. You only need to find the fully qualified name of the artifact as there is no `%%%` and `%%` in Maven (which justify the artifact name with scala.js and Scala version respectively) – Nader Ghanbari Oct 22 '14 at 17:25
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

- 897
- 3
- 14
- 21
-
1I'm curious, is it only for eclipse/scala IDE and not for maven in general? – tribbloid Dec 23 '18 at 22:18
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 optionallyscalajs-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.

- 21,805
- 2
- 61
- 91
-
Wow this is really painful but alas I don't have any more time to write a Maven plugin than the next guy. Drats! – Brian Topping Mar 07 '15 at 18:45
-
1Since this was written, Scala.js 0.6.x has been released, which at least publishes everything on Maven Central. Now all we need is a Maven plugin. ^^ (Or invoke the CLI.) – sjrd Mar 07 '15 at 19:28
-
1Do there exist any examples of how to compile and run a simple Scala.js hello-world program, that does not involve SBT? I have downloaded the command line interface, but there is not guidance on how to run the 3 commands in bin. scalajsc is pretty obvious, but I don't know how to go from there. – Eric Kolotyluk Mar 26 '15 at 21:47
-
1@Eric Kolotyluk Have a look at this document: https://github.com/scala-js/scala-js/blob/master/TESTING It's not documentation, but it shows how to use the CLI. – sjrd Mar 27 '15 at 06:30
-
That document helps somewhat, but is seriously lacking in comprehensibility. The first problem I encountered is the script for Windows, scalajsc.bat, is defective. Eventually I figure out how to compile Scala.js directly from scalac. I generated the test.js, but I am stymied at how to run this. It is hard to believe anyone has ever built a Scala.js app from the command line before when there is no actual documentation on how to do this. – Eric Kolotyluk Mar 27 '15 at 15:44
-
I might be inclined to write a scalajs-maven-plugin if someone could actually document the manual steps necessary to build a working scalajs application. Creating Maven plugins is not that hard. – Eric Kolotyluk Mar 27 '15 at 15:57
-
@EricKolotyluk I will gladly assist you in building a maven plugin for Scala.js. Have a look at the [Quick Linker](https://github.com/scala-js/scala-js/blob/master/tools/js/src/test/scala/org/scalajs/core/tools/test/js/QuickLinker.scala) we use for bootstrapping tests to see what is needed to link Scala.js. Best is if you contact me through gitter if you want to work on this. – gzm0 Apr 21 '15 at 20:16
-
Hi, is there a guide to the current command line options for scalajsld? The Quick Linker link above is now broken, and scalajsld 1.0.0-M5 gives "Error: Unknown option --jsoutput" when used with the maven config suggested in the other answer. – lmm Jul 15 '18 at 09:16
-
`scalajsld -h`, just like any other command-line program. Forget the `QuickLinker`. The simplest reference for how to programmatically invoke the linker is [`Scalajsld.scala`](https://github.com/scala-js/scala-js-cli/blob/master/src/main/scala/org/scalajs/cli/Scalajsld.scala) itself (the link is for 1.x). – sjrd Jul 15 '18 at 12:51