Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the proper setup of sbt-idea with sbt 0.11?

Tags:

sbt

sbt-idea

I am creating a Scala project with sbt 0.11.2 and sbt-idea and I am getting UNRESOLVED DEPENDENCIES on the gen-idea task.

I've just installed sbt (downloaded jar and made script as instructed in the wiki), followed the sbt-idea setup here, made an empty directory for my project, and run sbt and then run the gen-idea task.

It can't find the dependency because it only uses the built-in repos. How do I tell sbt to check another repo?


When I place the build.sbt file in the plugins dir and run sbt it starts resolving things, one of which is Resolving com.github.mpeltonen#sbt-idea;0.11.0 ...

Later in the process it downloads it successfully:

[info] downloading http://mpeltonen.github.com/maven/com/github/mpeltonen/sbt-idea_2.9.1_0.11.2/0.11.0/sbt-idea-0.11.0.jar ...
[info]  [SUCCESSFUL ] com.github.mpeltonen#sbt-idea;0.11.0!sbt-idea.jar (592ms)

When I run the gen-idea task, things look good at first...

> gen-idea
[info] Trying to create an Idea module default-b91f2c

It moves on to creating .idea directories and such, which seem to be created just fine. It then starts resolving things again (scala tools, sbt, commens-*, etc)

Eventually it tries to resolve sbt-idea:

[warn]  module not found: com.github.mpeltonen#sbt-idea;0.11.0
[warn] ==== local: tried
[warn]   /home/scaladev/.ivy2/local/com.github.mpeltonen/sbt-idea/scala_2.9.1/sbt_0.11.2/0.11.0/ivys/ivy.xml
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/com.github.mpeltonen/sbt-idea/0.11.0/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/github/mpeltonen/sbt-idea_2.9.1_0.11.2/0.11.0/sbt-idea-0.11.0.pom
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn]   http://scala-tools.org/repo-releases/com/github/mpeltonen/sbt-idea_2.9.1_0.11.2/0.11.0/sbt-idea-0.11.0.pom
[warn] ==== Scala-Tools Maven2 Snapshots Repository: tried
[warn]   http://scala-tools.org/repo-snapshots/com/github/mpeltonen/sbt-idea_2.9.1_0.11.2/0.11.0/sbt-idea-0.11.0.pom
[info] Resolving commons-io#commons-io;2.0.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.github.mpeltonen#sbt-idea;0.11.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.github.mpeltonen:sbt-idea:0.11.0 (sbtVersion=0.11.2, scalaVersion=2.9.1)
[warn] 

I understand that it wouldn't find it at those locations, but I don't understand why it didn't try the github repo, as it did when configuring the plugin. I was expecting to see a line looking something like this:

[warn] ==== sbt-idea-repo: tried
like image 871
Jack Dreep Avatar asked Dec 28 '11 22:12

Jack Dreep


People also ask

What are sbt settings?

A setting is something which can take the values stored at other Keys in the build state, and generates a new value for a particular build key. sbt converts all registered Setting[_] objects into a giant linear sequence and compiles them into a task graph. This task graph is then used to execute your build.

Which is the correct way to add dependencies in sbt file?

Library dependencies can be added in two ways: unmanaged dependencies are jars dropped into the lib directory. managed dependencies are configured in the build definition and downloaded automatically from repositories.

Which of the following Ides fully supports sbt?

IntelliJ IDEA is an IDE created by JetBrains, and the Community Edition is open source under Apache v2 license. IntelliJ integrates with many build tools, including sbt, to import the project. This is a more traditional approach that might be more reliable than using BSP approach.

How do we specify library dependencies in sbt?

You can use both managed and unmanaged dependencies in your SBT projects. If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.


2 Answers

gen-idea plugin for sbt 0.11.2 has not yet been published but 0.11.1-SNAPSHOT version should work as expected :

resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "0.11.1-SNAPSHOT")
like image 199
David Avatar answered Oct 16 '22 23:10

David


This is documented in the sbt-idea README file here. Specifically:

Add the following lines to ~/.sbt/plugins/build.sbt or PROJECT_DIR/project/plugins.sbt

resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "0.11.0")

NOTE: If you experience problems with sbt 0.11 installation, see this.

like image 34
Paul Butcher Avatar answered Oct 16 '22 23:10

Paul Butcher