7

I have added the following in build.sbt:

libraryDependencies <<= scalaVersion { scala_version => Seq(
 <other entries>
  "org.scalacheck" %% "scalacheck" % "1.10.0" % "test",
  <other entries>
  )
}

Upon compile the project in sbt, the dependencies are resolved successfully as can be seen in the logs:

[info] Resolving org.scalacheck#scalacheck_2.9.1;1.10.0 ...
...
Done updating

However, I get the following error during compilation of one file.

object scalacheck is not a member of package org
import org.scalacheck.Gen
      ^  

What can be the reason for this?

Is there a way to see the classpath that sbt is using during the compile task?

Sbt version: 0.11.2
OS: Windows 7
Scala version: 2.9.1

Note that the project builds fine in ScalaIDE. (I use sbteclipse to generate the eclipse .classpath file. The generated .classpath has proper scalacheck entry.)

Jacek Laskowski
  • 64,943
  • 20
  • 207
  • 364
dips
  • 1,557
  • 13
  • 21

1 Answers1

16

The way you import the dependency makes Scalacheck only available for the command test:

"org.scalacheck" %% "scalacheck" % "1.10.0" % "test"

You should use:

"org.scalacheck" %% "scalacheck" % "1.10.0"

But why do you use Scalacheck somewhere else than in tests ? See this link for more explanations about testing in sbt.

Lomig Mégard
  • 1,800
  • 13
  • 18
  • 2
    Also of note: use `test:compile` to compile stuff in `src/main/test`. This version will find the dependencies that were marked with `... % "test"` – Dylan Nov 27 '12 at 14:02
  • Thanks! It works now. Some of the `generators` and `shrink` methods that I am writing are non-trivial. Hence, I am keeping this code along with the class implementation in `src`. – dips Nov 27 '12 at 16:14