Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine crossProject and dependsOn

Tags:

sbt

scala.js

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]
^

like image 370
user79074 Avatar asked Jun 10 '15 09:06

user79074


1 Answers

Leave out the dependsOn for the web project.

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

It made the trick for me.

like image 82
Mikaël Mayer Avatar answered Nov 05 '22 06:11

Mikaël Mayer