How to install library with SBT libraryDependencies in an Intellij project
Asked Answered
C

1

6

I am very new to SBT, Breeze and IntelliJ, though I have a decent grasp of Scala and I am trying to install the Breeze library, which I think is managed.

What I've done:

I followed the instructions on this page and added this script to the build.sbt file in my project:

libraryDependencies  ++= Seq(
            // other dependencies here
            "org.scalanlp" %% "breeze" % "0.10",
            // native libraries are not included by default. add this if you want them (as of 0.7)
            // native libraries greatly improve performance, but increase jar sizes.
            "org.scalanlp" %% "breeze-natives" % "0.10"
)

resolvers ++= Seq(
            // other resolvers here
            "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"
)

// Scala 2.9.2 is still supported for 0.2.1, but is dropped afterwards.
scalaVersion := "2.11.1" // or 2.10.3 or later

I then ran sbt update in the project directory (via the terminal), and saw that all the pieces of Breeze downloaded.

I then tried re-running sbt update, but this did not trigger another download.

Issue:

The problem is that I cannot access the library via IntelliJ. import breeze._ gives the standard Cannot resolve symbol breeze and I couldn't find any mention of Breeze in "Project Structure." It isn't in the lib directory of the project either.

Am I missing a step?

Cymophane answered 21/5, 2015 at 15:10 Comment(6)
When you first opened the project was "auto-import" ticket in IntelliJ? If not it might be worth re-importing it from IntelliJ's main menuInvolucrum
That's very strange. I can't seem to toggle it to turn on... it literally doesn't respond. I tried restarting it, and still nothing.Cymophane
Delete the .idea folder from the project directory and try from scratch.Involucrum
Right, I found an alternative way Settings>Buid,Execution,Deployment>SBT>Use auto-import, but this hasn't fixed it.Cymophane
If you run "sbt compile" in a terminal is it successful? Is it just IntelliJ causing the issue?Involucrum
@Spork - Amazingly, simply recreating the project (by erasing .idea as you suggested) worked. I have no idea what happened, but in any case, it worked. Thank you! Please answer it officially so that I could accept your answer.Cymophane
I
6

Sounds like a bug in the IntelliJ project, try removing the .idea directory from the project directory and then re-import the project into IntelliJ using the wizard.

Involucrum answered 21/5, 2015 at 16:14 Comment(1)
...and select "Import from existing project model -> SBT" in the import wizard...Frizette

© 2022 - 2024 — McMap. All rights reserved.