How to reference an external sbt project from another sbt project?

I have the following setup for a Scala application and a shared core library: root

-> /ApplicationA -> /project -> /build.sbt -> /CoreLibrary -> /project -> /build.sbt 

I want to add a link from the ApplicationA link in the CoreLibrary to the Eclipse project so that every time the CoreLibrary changes ApplicationA, it is also created. I tried the following build.Scala content for ApplicationA:

  val core = Project( id = "platform-core", base = file("../CoreLibrary")) val main = Project(id = "application, base = file(".")).dependsOn(core) 

However, when compiling ApplicationA SBT complains that the dependency can only be a subdirectory !!:

 java.lang.AssertionError: assertion failed: Directory C:\git\CoreLibrary is not contained in build root C:\git\ApplicationA 

It seems quite simple, what is the right way to be addicted to this project?

+45
scala sbt
Jul 25 2018-12-25T00:
source share
3 answers

You can make an initial dependency on your project as follows:

  lazy val core = RootProject(file("../CoreLibrary")) val main = Project(id = "application", base = file(".")).dependsOn(core) 

I have a working example with the assembly of multimodal games: https://github.com/ahoy-jon/play2MultiModule/blob/master/playapp/project/Build.scala

But I think the right way (it depends on your context) is to create

  -> /project/ -> Build.scala -> /ApplicationA -> /project -> /build.sbt -> /CoreLibrary -> /project -> /build.sbt 

referring to two projects and the dependencies between them.

+38
Jul 25 2018-12-12T00:
source share

With sbt 0.12.1, it seems possible to get a simple link to the project:

I used ProjectRef instead of RootProject

http://www.scala-sbt.org/0.12.1/api/sbt/ProjectRef.html

 ProjectRef(file("../util-library"), "util-library") 

sbt-eclipse also works.

+18
Mar 05 '13 at 16:39
source share

Since sbt 0.13 , you can create definitions for several projects directly in .sbt without the need for a Build.scala file.

Thus, it would be sufficient to add the following to ApplicationA / project / build.sbt .

 lazy val core = RootProject(file("../CoreLibrary")) val main = Project(id = "application", base = file(".")).dependsOn(core) 
+10
Sep 30 '15 at 4:07
source share



All Articles