3

I use SBT 0.10.0.

How do I download/retrieve project dependencies?

For example, for slf4s only this line is mentioned:

val slf4s = "com.weiglewilczek.slf4s" %% "slf4s" % "1.0.6

Where do I need to put this line, and how do I get the library?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
snappy
  • 2,761
  • 5
  • 23
  • 24

3 Answers3

4

I presume you're using SBT 0.10.0, because earlier versions will put your deps in lib_managed automatically.

In build.sbt, put the following line:

retrieveManaged := true
opyate
  • 5,388
  • 1
  • 37
  • 64
  • I did add that line, but sbt does not seem to pick up my project/build/Project.scala file. Is there anything else to set? I use SBT 0.10.0 – snappy Jul 15 '11 at 18:49
  • 2
    It sounds like your project file is in the 0.7 location (`project/build`) instead of 0.10 (just `project`), See [this full example](https://github.com/harrah/xsbt/wiki/Full-Configuration-Example). – opyate Jul 16 '11 at 08:11
2

You create a project/build subdirectory in your project and put a scala file with the above content there.

Then when you start sbt from your project root directory the

update

command will retrieve your dependencies.

Note that it will only analyse your project configuration once by default. If you change it, you have to call reload

UPDATE:

let the project class extend DefaultProject:

class SomeProjectName(info: ProjectInfo) extends DefaultProject(info)
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
  • I added a file Project.scala import sbt._ import sbt.Keys._ class Project extends Build { val slf4s = "com.weiglewilczek.slf4s" %% "slf4s" % "1.0.6" } Is something wrong here? It does not get the library after update and refresh – snappy Jul 15 '11 at 07:18
  • For some reason sbt did not pick up the project class. But it did retrieve the library if I added this line in build.sbt: libraryDependencies += "com.weiglewilczek.slf4s" %% "slf4s" % "1.0.6" – snappy Jul 15 '11 at 19:07
  • 1
    This is because 0.10 finds `build.sbt`, and the suggestion above seems to be for 0.7. See [here](https://github.com/harrah/xsbt/wiki/Full-Configuration-Example) for a 0.10 project file example. – opyate Jul 16 '11 at 08:15
1

I don't know which version of sbt you are using.

For 0.10, Daniel C. Sobral made a blog post about creation of an sbt project: dcsobral-project-creation-guide

Maybe this helps.

Christian
  • 4,543
  • 1
  • 22
  • 31