How to combine crossProject and dependsOn

637 views Asked by At

I have a multi-project definition something like the following:

lazy val commonSettings = settings(
  libraryDependencies ++= Seq(
    "ch.qos.logback" % "logback-classic" % "1.1.2",
     ...
)

lazy val core = (project in file(".")).
  settings(commonSettings: _*).
  settings(...
)

lazy val web = (project in file("web")).
  settings(commonSettings: _*).
  settings(...
).dependsOn(core)

The problem is that I want to set up the web project to use the Scala JS client/server model. So I need to expand the web project to use crossProject to split into the js/jvm/shared parts. But I am not sure of the best way to achieve this. If I try to do something like:

lazy val web = crossProject.
  settings(commonSettings: _*).
  settings(...
).jsSettings(...
).jvmSettings(...
).dependsOn(core)

I get a compilation error for my build.scala:

... type mismatch; [error] found : sbt.Project [error] required: org.scalajs.sbtplugin.cross.CrossClasspathDependency [error] lazy val web = crossProject.settings().jsSettings().jvmSettings().dependsOn(core) [error]
^

1

There are 1 answers

0
Mikaël Mayer On BEST ANSWER

Leave out the dependsOn for the web project.

lazy val webJS = web.js.dependsOn(...)

It made the trick for me.