Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set dependency as runtime in SBT (to mimic runtime scope in Maven)?

Tags:

sbt

I have a dependency in runtime scope in a Maven project:

<dependency>
  <groupId>org.docbook</groupId>
  <artifactId>docbook-xml</artifactId>
  <version>4.4</version>
  <scope>runtime</scope>
</dependency>

How can I express this in SBT?

like image 827
Phil Avatar asked Dec 15 '22 03:12

Phil


1 Answers

You should use runtime configuration for the dependency in build.sbt as follows:

libraryDependencies += "org.docbook" % "docbook-xml" % "4.4" % "runtime"

With this, classpath should be properly set - show managedClasspath for compile and runtime configurations to verify it:

[sbt-13-0-1]> help dependencyClasspath
The classpath consisting of internal and external, managed and unmanaged dependencies.
[sbt-13-0-1]> show managedClasspath
[info] List(Attributed(/Users/jacek/.sbt/boot/scala-2.10.3/lib/scala-library.jar))
[success] Total time: 0 s, completed Jan 1, 2014 12:10:57 AM
[sbt-13-0-1]> show runtime:managedClasspath
[info] List(Attributed(/Users/jacek/.sbt/boot/scala-2.10.3/lib/scala-library.jar), Attributed(/Users/jacek/.ivy2/cache/org.docbook/docbook-xml/jars/docbook-xml-4.4.jar))
[success] Total time: 0 s, completed Jan 1, 2014 12:11:01 AM
like image 122
Jacek Laskowski Avatar answered May 04 '23 01:05

Jacek Laskowski