I have the following setup of a Scala application and a common core library: root
-> /ApplicationA -> /project -> /build.sbt -> /CoreLibrary -> /project -> /build.sbt
I want to add a reference from ApplicationA to CoreLibrary à la Eclipse project reference, so that every time CoreLibrary changes ApplicationA is built as well. I´ve tried the following contents of build.Scala 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 a dependency can only be a subdirectory!!:
java.lang.AssertionError: assertion failed: Directory C:\git\CoreLibrary is not contained in build root C:\git\ApplicationA
This seems completely straightforward, what's the correct way of having this project dependency?
The libraryDependencies key Most of the time, you can simply list your dependencies in the setting libraryDependencies . It's also possible to write a Maven POM file or Ivy configuration file to externally configure your dependencies, and have sbt use those external configuration files.
A project is defined by declaring a lazy val of type Project. For example, : lazy val util = (project in file("util")) lazy val core = (project in file("core")) The name of the val is used as the subproject's ID, which is used to refer to the subproject at the sbt shell.
All new SBT versions (after 0.7. x ) by default put the downloaded JARS into the . ivy2 directory in your home directory. If you are using Linux, this is usually /home/<username>/.
You can do a source dependency on your project like that :
lazy val core = RootProject(file("../CoreLibrary")) val main = Project(id = "application", base = file(".")).dependsOn(core)
I have a working example with a multimodule play build : https://github.com/ahoy-jon/play2MultiModule/blob/master/playapp/project/Build.scala
But I think the proper way (it depends of your context) of doing it is to create a
-> /project/ -> Build.scala -> /ApplicationA -> /project -> /build.sbt -> /CoreLibrary -> /project -> /build.sbt
referencing the two projects and the dependencies between them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With