Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does sbt give "object scalacheck is not a member of package org" after successful scalacheck resolve?

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.)

like image 597
dips Avatar asked Nov 27 '12 11:11

dips


1 Answers

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.

like image 183
Lomig Mégard Avatar answered Jan 03 '23 21:01

Lomig Mégard