From ad22b61d98b5c7edde4ef1bf1a9e1f7fe98c9fa8 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Tue, 18 Oct 2011 15:06:41 -0400 Subject: [PATCH] add a teaser about libraryDependencies to the basic def page --- Getting-Started/Getting-Started-Basic-Def.md | 31 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Getting-Started/Getting-Started-Basic-Def.md b/Getting-Started/Getting-Started-Basic-Def.md index 4a98395..3e1b7cf 100644 --- a/Getting-Started/Getting-Started-Basic-Def.md +++ b/Getting-Started/Getting-Started-Basic-Def.md @@ -83,8 +83,8 @@ this is that you can't define a `val` or `object` in `build.sbt`. On the left, `name`, `version`, and `scalaVersion` are _keys_. A key is an instance of `SettingKey[T]`, `TaskKey[T]`, or -`InputKey[T]` where `T` is the expected value type. The kinds -of key are explained more below. +`InputKey[T]` where `T` is the expected value type. The kinds of +key are explained more below. Keys have a method called `:=`, which returns a `Setting[T]`. You could use a Java-like syntax to call the method: @@ -124,6 +124,33 @@ The other transformations require an understanding of [[scopes|Getting Started S [[next section|Getting Started Scopes]] is about scopes and the [[section after that|Getting Started More About Settings]] goes into more detail about settings. +## Adding library dependencies + +To depend on third-party libraries, there are two options. The +first is to drop jars in `lib/` (unmanaged dependencies) and the +other is to add managed dependencies, which will look like this in +`build.sbt`: + +```scala +libraryDependencies += "org.apache.derby" % "derby" % "10.4.1.3" +``` + +This is how you add a managed dependency on the Apache Derby +library, version 10.4.1.3. + +The `libraryDependencies` key involves two complexities: `+=` +rather than `:=`, and the `%` method. `+=` appends to the key's +old value rather than replacing it, this is explained in +[[more about settings|Getting Started More About Settings]]. The +`%` method is used to construct an Ivy module ID from strings, +explained in +[[library dependencies|Getting Started Library Dependencies]]. + +We'll skip over the details of library dependencies until later in +the Getting Started Guide. There's a +[[whole page|Getting Started Library Dependencies]] covering it +later on. + ## Task Keys There are three flavors of key: