如何在SBT中将依赖关系设置为运行时(以模仿Maven中的运行时范围)?

时间:2013-12-26 05:48:20

标签: sbt

我在Maven项目的runtime范围内有依赖关系:

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

我如何在SBT中表达这一点?

1 个答案:

答案 0 :(得分:6)

您应该使用运行时配置为build.sbt中的依赖项,如下所示:

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

这样,应该为show managedClasspathcompile配置正确设置类路径runtime以验证它:

[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