Incerteza
Incerteza

Reputation: 34944

Unable to add scala-reflect as a dependency

I can't add scala-reflect as dependency. My project/build.sbt looks like this:

//the name of the project, will become the name of the war file when you run the package command.
name := "Test-SBT"

version := "1.0"

//specify which Scala version we are using in this project.
scalaVersion := "2.10.3"

libraryDependencies <++= (scalaVersion)(sv =>
  Seq(
    "org.scala-lang" % "scala-reflect" % "2.10.3",
    "org.scala-lang" % "scala-compiler" % "2.10.3"
  )
)

And project/build.properties

sbt.version=0.13.0

And here is my Main class:

object Main1 extends App {
  import scala.reflect.runtime.universe
  val runtimeMirror = universe.runtimeMirror(getClass.getClassLoader)
  //......
}

It says object runtime is not a member of package reflect. Of course, I did "gen-idea", "clean" and other things. What's up with that?

Upvotes: 3

Views: 4788

Answers (1)

pedrofurla
pedrofurla

Reputation: 12783

Guessing here due the question by @laughedelic.

The build.sbt should be in the root. Assuming the project you are writing is in test-sbt, you should end up with structure similar to:

test-sbt/build.sbt 
test-sbt/project 

Otherwise the build.sbt is used in creating the "internal compile project" used by SBT.

A deeper explanation can be found at SBT's docs sbt is recursive.

Upvotes: 5

Related Questions