6

I want to use scalax.io._ to manipulate file operations with SBT.

When I ran it, I got the error message showing scalax is not found.

>sbt run
import scalax.io._
[error]        ^
[error] iotest.scala:49: not found: object scalax

How to find the library dependency for this particular one?

A more general question, how to obtain the library dependency information for any library? For example, if I need use actor in scala, I need specify a library dependency. How to find the library dependency?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
derek
  • 9,358
  • 11
  • 53
  • 94

1 Answers1

7

"the library dependency information for any library" is part of the library's documentation and the author(s) is supposed to publish the info for different project management tools, sbt including. After all, what would be the purpose of developing a library that's hard to use?

Use http://search.maven.org/ to search for a library, and when you search for scala-io you'll get a list of available scala-io libraries.

Since I've never worked with the library I copied the ScalaIOExample example from Scala IO Documentation to have a working example. It needs the scalax.io and scalax.file packages that are distributed as scala-io-file artifact. Searching for the artifact leads to Artifact Details For com.github.scala-incubator.io:scala-io-file_2.10:0.4.2 with information on how to use it with Scala SBT in Dependency Information section.

With this, I created the following build.sbt in a sbt project:

scalaVersion := "2.10.3"

libraryDependencies += "com.github.scala-incubator.io" %% "scala-io-file" % "0.4.2"

It will add scala-io-file_2.10-0.4.2.jar to classpath and executing run in the project gives the following results:

$ 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
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420