Haspemulator Haspemulator - 23 days ago 9
Scala Question

Scala.js cross-project wrong dependency

In my

build.sbt
I have a cross-project (js + jvm), and I depend on the jvm part in my other project (let’s call it
events
). Here’s the part of my
build.sbt
:

lazy val common = (crossProject in file(“common”)).enablePlugins(ScalaJSPlugin)
lazy val common_js = common.js
lazy val common_jvm = common.jvm
lazy val events = (project in file (“events)).dependsOn(common_jvm)


But this setup fails when I do
sbt events/assembly
. The error is as follows:

java.lang.RuntimeException: deduplicate: different file contents found in the following:
JS_DEPENDENCIES
/Users/riakovle/.coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.11/0.6.13/scalajs-library_2.11-0.6.13.jar:JS_DEPENDENCIES


If I do the
dependencyGraph
, I see my
events
project depends on
common:common_sjs0.6_2.11:0.1-SNAPSHOT
, and the aforementioned
scalajs-library
comes transitively from it.
So it seems my common js dependency creeps in somehow, even though I haven't specified it. What am I doing wrong?

Answer

You are probably specifying the ScalaJSPlugin on the JVM project, either directly or via crossProject. The plugin is only needed when creating a regular SBT project, as crossProject includes it automatically for the JS subproject.