23

I'm using *.scala files in the project folder for configuring my SBT project. I'm using IDEA12 with the Scala Plugin and sbt-idea for generating the project. After calling gen-idea in the SBT shell, everything works fine except for one thing. When I click go to declaration on some method in my project code, IDEA shows me how it is implemented (redirects me to the library sources). But when I'm trying to "inspect" SBT's internal sources it shows me something like this:

def settings: Seq[Setting[_]] = { /** compiled code **/ }

How can I attach SBT sources to my IDEA project?

I'm using SBT 0.12.3.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102

2 Answers2

42

In SBT there are two command which may interest you:

update-classifiers - will download all sources and documentation for all libs in your project
update-sbt-classifiers - downloads sbt sources and docs

This will download all the sources you need. To make an IDEA project with them just call gen-idea sbt-classifiers.

If you don't want to call each time this commands for re-generating you project, you should add something like this to your build.sbt: addCommandAlias("make-idea", ";update-classifiers; update-sbt-classifiers; gen-idea sbt-classifiers").

aholub7x
  • 808
  • 12
  • 26
4lex1v
  • 21,367
  • 6
  • 52
  • 86
  • just 'gen-idea sbt-classifiers' should be enough – OlegYch Jun 16 '13 at 15:45
  • 1
    It also works for Play! project. Type same commands in Play console: update-sbt-classifiers ..and then gen-idea sbt-classifiers – Espinosa Jul 27 '14 at 09:13
  • 2
    You losing first semicolon `addCommandAlias("make-idea", ";update-classifiers; update-sbt-classifiers; gen-idea sbt-classifiers")` – HEX Oct 28 '14 at 12:00
  • When I do that I get `[error] Not a valid command: sbt-classifiers` please help – samthebest Oct 28 '14 at 19:21
  • 6
    you need to have `sbt-idea` added to your plugins, @samthebest: `addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")` – Cpt. Senkfuss Jan 22 '15 at 19:00
  • None of the answers here work with sbt 1.x or with 2022.2 IntellilJ – it still can't find SBT sources. – Nikita Dec 02 '22 at 06:56
4

As of sbt version 1.2.8, the command is changed to:
sbt updateClassifiers - to download all sources and docs
sbt updateSbtClassifiers - to download sbt sources and docs.

Ritesh Puj
  • 126
  • 5