Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scalacheck/scalatest not found: how to add it in sbt/scala?

I've installed typesafe-stack from http://typesafe.com/stack/download on my ubuntu12, than I created a play project (g8 typesafehub/play-scala) and now I want to add scalatest or scalacheck to my project.

So my_app/project/plugins.sbt has the following lines:

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.0.1")

Then I added scalatest using addSbtPlugin:

addSbtPlugin("org.scalatest" %% "scalatest" % "2.0.M1" % "test")

and now it fails with the following message when I run 'sbt test'

[info] Resolving org.scalatest#scalatest;2.0.M1 ...
[warn]  module not found: org.scalatest#scalatest;2.0.M1
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== local: tried
[warn]   ~/.ivy2/local/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== Typesafe repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-    releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== public: tried
[warn]     http://repo1.maven.org/maven2/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom

What I don't understand: why does it use this http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom URL instead of the real one http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1/2.0.M1/scalatest_2.9.1-2.0.M1.pom?

Quite the same problem I have with scalacheck: it also tries to download using sbt-version specific artifactId whereas the repository has only scala-version specific.

What am I doing wrong? I understand there must be a switch in sbt somewhere, not to use sbt-version as part of the artifact URL?

I also tried using this in my plugins.sbt

libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M1" % "test"

but looks like it is completely ignored by sbt and scalatest.jar hasn't appeared in the classpath:

my_app/test/AppTest.scala:1: object scalatest is not a member of package org
[error] import org.scalatest.FunSuite

because the output of sbt clean && sbt test has lots of Resolving org.easytesting#fest-util;1.1.6 or just another library, but nothing about scalatest.

I use scala 2.9.1 and sbt 0.11.3, trying to use scalatest 2.0.M1 and 1.8; scalacheck:

resolvers ++= Seq(
  "snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
  "releases"  at "http://oss.sonatype.org/content/repositories/releases"
)

libraryDependencies ++= Seq(
  "org.scalacheck" %% "scalacheck" % "1.9" % "test"
)

With the same outcome, i.e. it uses the sbtVersion specific POM URL, which doesn't exist.

What am I doing wrong? Thanks.

like image 307
pavel Avatar asked Jun 01 '12 00:06

pavel


2 Answers

Scalatest is not a build plugin, but a testing library. You should add it like this:

libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M1" % "test"

And you should add it to build.sbt at the base directory of your project (which you referred to as "my_app"), not to project/plugins.sbt.

The reason it has 0.11.3 in the URL it tries to find is because build plugins are tied to the version of SBT you are using.

like image 78
Daniel C. Sobral Avatar answered Oct 12 '22 14:10

Daniel C. Sobral


The plugins.sbt file and the addSbtPlugin are used to add sbt plugins. Not dependencies.

With the template you used, you should add your dependencies in the project/Build.scala. You will find a section with:

val appDependencies = Seq(
  // Add your project dependencies here,
)

Replace it with:

val appDependencies = Seq(
  "org.scalacheck" %% "scalacheck" % "1.9" % "test",
  "org.scalatest" %% "scalatest" % "2.0.M1" % "test"
)

and it should work.

like image 22
paradigmatic Avatar answered Oct 12 '22 13:10

paradigmatic