I have a set of loosely related components where some of these depend on others. For concreteness, lets assume we have components "common", "a" and "b". "common" does not have any dependencies, but all other projects use "common". Furthermore, "a" depends on "b". All components are written in Scala, and I would like to use sbt to build them.
The following properties would be nice to have:
As far as I can see, there are two possibilities to have dependencies of this kind in sbt; either we use sub-projects, or use a managed dependency (that is pushed somewhere, e.g., locally). However, it seems that both of these options don't provide either (1) or (2) above. In particular
Is there really no way to say that an sbt project depends on another sbt project at a certain (relative) location, and having sbt figure out when to build the dependency?
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>/.
The publishLocal action is used to publish your project to your Ivy local file repository, which is usually located at $HOME/. ivy2/local/ . You can then use this project from other projects on the same machine.
With SBT you can use source dependencies.
lazy val root = Project("root", file("."), settings = ...) dependsOn(dispatchLiftJson)
lazy val dispatchLiftJson = uri("git://github.com/dispatch/dispatch-lift-json#0.1.0")
It will fetch from git in this example. You may be able to specify a file location on disk, although I can't find examples. Possibly
lazy val dep = file("/path/to")
or
lazy val dep = uri("file:///path/to")
I'm struggling with this myself - at the moment im using the publish-local method which is working ok.
Given directories
/build/some_app/
/build/some_lib/
File /build/some_app/build.sbt
:
lazy val someLib = ProjectRef(file("../some_lib"), "exportedSomeLib")
// = RootProject(file("../some_lib")) also works?
lazy val root = (project in file("."))
.dependsOn(someLib)
In /build/some-lib/build.sbt
:
lazy val exportedSomeLib = (project in file("."))
Caveat: note that items defined in both root scopes of these files will not always lead to errors, but silently change values in the global (?) scope if the keys (=the value names) clash across .sbt files. 😞
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