Search code examples
eclipsescalasbtspecs2scala-ide

Not able to import Specs2 in eclipse (scala-ide) project


Kindly consider if there's something very stupid I am missing, I am very new to this.

Creating this example on Eclipse (Scala-ide). When I create the CorrelationJobTest.scala class, there's a problem in importing classes from specs2 package.

import org.specs2.runner.JUnitRunner

The error I am getting is pretty obvious,

object specs2 is not a member of package org

Even after creating a build.sbt file, adding the dependencies, and doing a sbt clean, the error is still showing. Below is my build.sbt

name := "SparkCorrelation"

organization := "com.xyz"

version := "0.1"


/* scala versions and options */
scalaVersion := "2.10.4"

// These options will be used for *all* versions.

javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation")
scalacOptions ++= Seq("-feature", "-unchecked", "-deprecation")

/* dependencies */
libraryDependencies ++= Seq("org.specs2" %% "specs2-core" % "3.7" % "test")

scalacOptions in Test ++= Seq("-Yrangepos")

EDIT: I faced this problem with apache.spark packages too. Then I included the jar spark-assembly-1.6.0-hadoop-2.6.0.jar and it got solved. Isn't there a library for specs2 that I can import in Eclipse?


Solution

  • Got it working. Here's what I did:

    1. Deleted the project from eclipse
    2. Did sbt eclipse
    3. Imported the project into eclipse again.
    4. Added dependencies in build.sbt
    5. Did sbt clean

    The problem was that the project was directly created in eclipse and was not able to link to sbt build file.