1

I have installed Eclipse Luna. Then I installed Scala IDE via Help -> Install new software and adding software site with link from here. Then I installed sbt 0.13 and sbteclipse using this mini-guide and created eclipse project. Then I installed (kindda) scalatest by adding it to my build.sbt. Now it looks like this:

val scalaTest = "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"

lazy val commonSettings = Seq(
  scalaVersion := "2.11.6"
)

lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    libraryDependencies += scalaTest
  )

Then I created a test from this example. The file called FirstSpec.scala is located in testProject/src/test/scala-2.11/testProject/. So here is a problem: eclipse seems to not see scalaTest. The second line with import org.scalatest._ is underlined red with error description object scalatest is not a member of package org. And, following this guide, I don't see the option Run As -> ScalaTest - Suite when choosing my test class. At the same time everything goes good and fine when I start sbt session in my test project and type test command. The tests launches and passes.

So my questions are:

  • why eclipse doesn't see the scalatest if I put it in build.sbt's libraryDependencies? What's the point of libraryDependencies then?
  • Why sbt test runs the tests without a problem? If sbt sees scalatest, why eclipse can't?
Vadim Samokhin
  • 3,378
  • 4
  • 40
  • 68

1 Answers1

0

Whew, this one resolved my issue. So, build.sbt example might go something like:

import com.typesafe.sbteclipse.plugin.EclipsePlugin._

EclipseKeys.withSource := true

val scalaTest = "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
val jodaConvert = "org.joda" % "joda-convert" % "1.7"
val joda = "joda-time" % "joda-time" % "2.7"

lazy val commonSettings = Seq(
  scalaVersion := "2.11.6"
)

lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    libraryDependencies += scalaTest
  ).
  settings(
    libraryDependencies += jodaConvert
  ).
  settings(
    libraryDependencies += joda
  )

Then do this:

rm -rf  ~/.ivy2/cache/

sbt update-classifiers

sbt eclipse
Community
  • 1
  • 1
Vadim Samokhin
  • 3,378
  • 4
  • 40
  • 68