如何在SBT中添加scalax.io作为依赖?

der*_*rek 5 sbt

我想用来scalax.io._操纵SBT的文件操作.

当我运行它时,我收到了错误消息scalax is not found.

>sbt run
import scalax.io._
[error]        ^
[error] iotest.scala:49: not found: object scalax
Run Code Online (Sandbox Code Playgroud)

如何找到这个特定的库依赖?

一个更一般的问题,如何获取任何库的库依赖信息?例如,如果我需要在scala中使用actor,我需要指定一个库依赖项.如何找到库依赖?

Jac*_*ski 7

"任何库的库依赖信息"是库文档的一部分,作者应该发布不同项目管理工具的信息,包括.毕竟,开发一个难以使用的库的目的是什么?

使用http://search.maven.org/搜索库,当您搜索时,scala-io您将获得可用scala-io库列表.

由于我从未使用过该库,因此我从Scala IO Documentation中复制了ScalaIOExample示例以获得一个工作示例.它需要和作为工件分发的包.搜索工件会导致工件详细信息,请参阅com.github.scala-incubator.io:scala-io-file_2.10:0.4.2,其中包含有关如何在依赖关系信息部分中使用Scala SBT的信息.scalax.ioscalax.filescala-io-file

有了这个,我build.sbt在一个sbt项目中创建了以下内容:

scalaVersion := "2.10.3"

libraryDependencies += "com.github.scala-incubator.io" %% "scala-io-file" % "0.4.2"
Run Code Online (Sandbox Code Playgroud)

它会将scala-io-file_2.10-0.4.2.jar添加到classpath并在项目中执行run会产生以下结果:

$ sbt run
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/stackoverflow/sbt-scala-io/project
[info] Set current project to sbt-scala-io (in build file:/Users/jacek/sandbox/stackoverflow/sbt-scala-io/)
[info] Running ScalaIOExample
Not interrupting system thread Thread[Keep-Alive-Timer,8,system]
Not interrupting system thread Thread[Keep-Alive-SocketCleaner,8,system]
[success] Total time: 5 s, completed Dec 31, 2013 11:16:42 PM
Run Code Online (Sandbox Code Playgroud)