Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specific syntax to scope library dependencies in SBT?

Tags:

scala

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"
like image 979
Sebastien Lorber Avatar asked Jul 30 '13 20:07

Sebastien Lorber


1 Answers

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.

like image 148
Mark Harrah Avatar answered Oct 04 '22 18:10

Mark Harrah