1

I'm developing a Scala application in IntelliJ Idea 12. I have sbt plugin for Idea installed (Setting -> Plugins -> Browse repositories ...). Now I want to use some extra libraries for Scala, let's say one of them is https://github.com/stevej/scala-json. So I downloaded zip file from its source code from its github repository.

What do I do next? What is the standard way of adding a third-party library to Scala project using Intelli Idea 12 with SBT plugin installed?

Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
  • 2
    The standart way to adding libraries is to write library meta in SBT build file, so SBT may resolve dependencies on it's own. After `sbt update` you have to issue `sbt gen-idea` to get familiarize IDEA with downloaded jars. See also http://stackoverflow.com/questions/4250318/how-to-create-sbt-project-with-intellij-idea – om-nom-nom May 29 '13 at 06:47
  • @om-nom-nom but, as I said, I have sbt plugin installed in Idea. can't your solution be simplified because of this? I don't know how exactly, though. – Alan Coromano May 29 '13 at 06:50
  • and also, there is no file *.sbt in my project. – Alan Coromano May 29 '13 at 06:53
  • IIRC, the main goal of third party plugin is to provide embedded REPL -- it doesn't do anything about dependency resolving. IDEA team working of full integration of SBT right now and said to deliver such feature quite soon. See ["General usage instructions"](http://plugins.jetbrains.com/plugin?pluginId=5007) section – om-nom-nom May 29 '13 at 06:54
  • @om-nom-nom, I didn't ask about that. – Alan Coromano May 29 '13 at 07:06
  • 1
    *What is the standard way of adding a third-party library to Scala project using Intelli Idea 12 with SBT plugin installed?* Current version of IDEA SBT plugin do not make a ANY difference from the point of dependency resolution. You had to switch back to [the usual SBT stuff](http://www.scala-sbt.org/release/docs/index.html) and then convert it in a format that IDEA understands via `sbt gen-idea` every time you make changes to build definition. – om-nom-nom May 29 '13 at 07:12
  • it says "[error] Not a valid command: gen-idea" – Alan Coromano May 29 '13 at 07:19
  • you have to setup sbt-idea plugin first, [link](http://stackoverflow.com/questions/4250318/how-to-create-sbt-project-with-intellij-idea) I've already provided in first comment contains instructions – om-nom-nom May 29 '13 at 07:21
  • @om-nom-nom your first comment should have been the answer ;D – starscream_disco_party May 03 '17 at 14:50

1 Answers1

2

Try something like this in the .sbt file:

libraryDependencies ++= Seq(                            
    "com.typesafe.slick" %% "slick" % "1.0.0",
    "postgresql" % "postgresql" % "9.1-901-1.jdbc4",
    "org.scalatest" %% "scalatest" % "1.9.1",
    "net.sf.opencsv" % "opencsv" % "2.3",
    "org.apache.commons" % "commons-math3" % "3.0"              
)

you have to create your .sbt file in your project directory if you don't have one.

This is a quick tutorial on sbt (and another one)

Luther Blissett
  • 238
  • 1
  • 10