0

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?

Piyush Shrivastava
  • 1,046
  • 2
  • 16
  • 43

2 Answers2

1

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.

Piyush Shrivastava
  • 1,046
  • 2
  • 16
  • 43
0

You need to add the junit module to your dependencies

libraryDependencies ++= Seq(
  "org.specs2" %% "specs2-core" % "3.7" % "test",
  "org.specs2" %% "specs2-junit" % "3.7" % "test")
Eric
  • 15,494
  • 38
  • 61
  • Added but nothing happened. – Piyush Shrivastava Jan 19 '16 at 07:38
  • Did you create your specification file in `src/test/scala` and not `src/main/scala`? – Eric Jan 19 '16 at 07:43
  • You mean build.sbt? It is in the project folder. Do I have to create it somewhere else? – Piyush Shrivastava Jan 19 '16 at 07:45
  • I was meaning the `CorrelationJobTest.scala` file but I can see it is in the right place. I'll try to see if I can reproduce the issue. – Eric Jan 19 '16 at 07:57
  • What I did was 1. Created an eclipse project 2. Created build.sbt, included the dependencies, did `sbt clean` 3. Created all the src files. 4. Got this error – Piyush Shrivastava Jan 19 '16 at 08:16
  • Does it work fine with sbt on the command line? I have compilation errors on my side `Users/etorreborre/projects/scala/sequenceiq-samples/spark-correlation/src/main/scala/com/sequenceiq/spark/Main.scala:3: object apache is not a member of package org [error] import org.apache.spark.{SparkContext, SparkConf}` – Eric Jan 19 '16 at 08:18
  • This means that sbt or eclipse is not able to find the relevant dependencies. – Eric Jan 19 '16 at 08:19
  • I added the spark library into the project. See the EDIT in the question. – Piyush Shrivastava Jan 19 '16 at 09:10
  • You can download specs2 jars from here: `https://oss.sonatype.org/content/repositories/releases/org/specs2/specs2-core_2.11/3.7` (put `junit` instead of `core` for the JUnit one). – Eric Jan 19 '16 at 10:16