Alexey Romanov
Alexey Romanov

Reputation: 170815

Optional dependency in SBT

Maven has the optional dependency concept. Search of the SBT documentation for optional dependencies finds only "However, sometimes we have optional dependencies for special features.".

How can I declare an optional dependency in SBT?

Upvotes: 7

Views: 2052

Answers (1)

Alexander B
Alexander B

Reputation: 1033

Unfortunately SBT documentation doesn't list all available scopes that map to Ivy Configurations, but the source code does: https://github.com/sbt/sbt/blob/0.13/ivy/src/main/scala/sbt/Configuration.scala

You can do this in the same way you scope a dependency for test, runtime or provided scope.

libraryDependencies += "group id" % "artifact id" % "version" % "optional"

or

libraryDependencies += "group id" % "artifact id" % "version" % Optional

Upvotes: 10

Related Questions