Sebastien Lorber
Sebastien Lorber

Reputation: 92112

Specific syntax to scope library dependencies in SBT?

http://www.scala-sbt.org/0.12.2/docs/Getting-Started/Library-Dependencies.html

If you want a dependency to show up in the classpath only for the Test configuration and not the Compile configuration, add % "test" like this:

libraryDependencies += "org.apache.derby" % "derby" % "10.4.1.3" % "test"

Can someone explain why we use this notation? I mean the configuration at the end?

Why don't we write something like that:

libraryDependencies in Test += "org.apache.derby" % "derby" % "10.4.1.3"

Upvotes: 12

Views: 6643

Answers (1)

Mark Harrah
Mark Harrah

Reputation: 7019

The configuration as a string at the end is an Ivy configuration and is more accurately described as a configuration mapping. in Test doesn't cover all use cases, although it does cover the common ones.

The Detailed-Topics/Dependency-Management page for 0.13 has more information on it as well. Configurations are an Ivy feature. They can be thought of as a generalization of Maven's scopes.

Note that anything beyond Maven scopes requires metadata in the form of an ivy.xml. This is the case for metadata published to the local repository with publish-local, published to an Ivy repository, or when used within a local build before publishing. Metadata in the form of a pom.xml, such as that coming from Maven Central, is restricted to the standard Maven scopes.

Upvotes: 5

Related Questions