Specs2 on OSX - error: object specs2 is not a member of package org

I am trying to run some Scala code on my OSX machine and keep getting the error

error: object specs2 is not a member of package org

I have version 2.9.1-1 installed from Scala. I am also using verison 0.7.7 from sbt

My build.sbt file looks like this

name := "Comp-338-Web-App"

version := "1.0"

scalaVersion := "2.9.1"

scalacOptions += "-deprecation"

libraryDependencies ++= Seq(
  "junit" % "junit" % "4.7",
  "org.specs2" %% "specs2" % "1.8.2" % "test",
  "org.mockito" % "mockito-all" % "1.9.0",
  "org.hamcrest" % "hamcrest-all" % "1.1"
)

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

      

I've tried a bunch of different things, but can't get it to run the test correctly.

Any advice?

Let me know if you need more information about the settings on my computer.

+3


source to share


2 answers


The solution looks simple: use the latest version of sbt, currently 0.11.2.



The 0.7.x version in use doesn't know how to use build.sbt, which was only introduced in sbt 0.9 or so.

+3


source


In addition to moving to sbt 0.11.2, I recommend a completely complete configuration , although the author recommends using the .sbt descriptor for most of the task and only using the .scala descriptor if you cannot achieve anything with the .sbt syntax or use subprojects (for all my projects, I clearly separate the different parts of the application).

Below is an example of a project setup that I am using for a project I just started, so it only has the specs2 dependency:



import sbt._
import Keys._

object BuildSettings {
  val buildOrganization = "net.batyuk"
  val buildScalaVersion = "2.9.1"
  val buildVersion = "0.1"

  val buildSettings = Defaults.defaultSettings ++ Seq(organization := buildOrganization,
    scalaVersion := buildScalaVersion,
    version := buildVersion)
}

object Resolvers {
  val typesafeRepo = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
  val sonatypeRepo = "Sonatype Releases"  at "http://oss.sonatype.org/content/repositories/releases"

  val scalaResolvers = Seq(typesafeRepo, sonatypeRepo)
}

object Dependencies {
  val specs2Version = "1.8.2"

  val specs2 = "org.specs2" %% "specs2" % specs2Version
}

object IdefixBuild extends Build {

  import Resolvers._
  import Dependencies._
  import BuildSettings._

  val commonDeps = Seq(specs2)

  lazy val idefix = Project("idefix", file("."), settings = buildSettings ++ Seq(resolvers := scalaResolvers,
                                                                                     libraryDependencies := commonDeps))
}

      

0


source







All Articles