Built-in SBT Support in IntelliJ IDEA 13

Today we are happy to announce that the built-in support for SBT projects is finally here. The newest version of Scala plugin for IntelliJ IDEA 13 (0.23.308) comes with the following list of features:

  • Import SBT project
  • Auto-import SBT projects
  • Highlighting for .sbt files

To import an SBT project please use one of these options:

  1. File → Open, then choose .sbt file to import it as project
  2. File → Import Project, then choose .sbt file or directory containing SBT project

Don’t forget to use Enable auto-import checkbox to have your IntelliJ IDEA project automatically synchronized with .sbt files.

More cool features as well as the support for integration between Play 2.0 and SBT are coming soon. Please feel free to share your feedback, feature requests or just report found bugs to our issue tracker.

If you’d like to contribute or check out the sources use these two projects:

Enjoy!

This entry was posted in New Features and tagged , , . Bookmark the permalink.

99 Responses to Built-in SBT Support in IntelliJ IDEA 13

  1. Charles Monge says:

    Hi, any plan to support Android project written in Scala and built on Sbt ?

    Right now we are using sbt-idea which works… Some times :-)

  2. Evgeny Goldin says:

    Thanks, team! Just in time for a Coursera course.

  3. Daniel Chan says:

    What would be the benefits over something like https://github.com/mpeltonen/sbt-idea ?

  4. Li Haoyi says:

    Question: does this work with Build.scala files rather than build.sbt? I poked around and couldn’t figure out how to get it to import the thing; in particular, trying to select project/Build.scala in the [import] dialog failed

    • Pavel Fatin says:

      You may (always) select the project root directory in the import dialog.

      • Pierre-Yves Saumont says:

        From you answer, I guess we can deduce that it is is supposed to work.
        However, in our case, it doesn’t. It produces the following error message:

        Premature end of file.
        Consult IDE log for more details (Help | Show Log)

        and the logs say:

        2014-01-10 17:33:26,244 [4042592] WARN – ctExternalProjectImportBuilder – java.lang.reflect.UndeclaredThrowableException
        at $Proxy3.resolveProjectInfo(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        .
        .
        .
        Caused by: com.intellij.openapi.externalSystem.model.ExternalSystemException: Premature end of file.
        at org.jetbrains.sbt.project.SbtProjectResolver.resolveProjectInfo(SbtProjectResolver.scala:30)
        at org.jetbrains.sbt.project.SbtProjectResolver.resolveProjectInfo(SbtProjectResolver.scala:18)

        So, since the project works fine with SBT and imports fine with the SBT Eclipse plugin, and since IDEA is able to import the generated Eclipse project, I guess we can say that no, it does not work.

  5. wangzaixiang says:

    I Just download the Idea 13(133.79) and the lastest scala plugin(0.23.311), but has the following problem:

    1. when editing a single build.sbt file like:

    name := “demo”

    it reports that “Cannot resolve symbol name”

    2. I cant find anywhere to runing the SBT console or any sbt command.

    So what is the problem?

    • Alexander Podkhalyuzin says:

      You have to import SBT project first, then you will be able to edit build.sbt file.
      There is no SBT console in current implementation, just autosyncronization of project dependencies.

      Best regards,
      Alexander Podkhalyuzin.

      • Evgeny says:

        Hi!
        Thanks for your work!

        Is SBT console planned? I would like to use it. Also, would be great if I can run any SBT task before any run configurations.

    • Pavel Fatin says:

      We’ll probably add an automatic notification that offers to import or re-import project on viewing/editing such .sbt files (SCL-6282).

  6. Bijou Trouvaille says:

    I already have projects that I used sbt gen-idea for. Should I re-import them using the IDE to get the benefit of auto-import, or can I find this checkbox elsewhere?

    • Alexander Podkhalyuzin says:

      sbt gen-idea is third-party plugin, and it’s not related to our SBT support. So if you want to move to our SBT support you need to reimport it from the IDE.

      Best regards,
      Alexander Podkhalyuzin.

  7. Dmitriy Yefremov says:

    Hi folks. I installed the new Intellij today. I tried to import an SBT project using the new integration plugin. Here is the error I got: http://pastebin.com/bfQnF5pd

    Is there something I can do to get it working?

  8. Pingback: Play Framework and IntelliJ IDEA 13

  9. Greg says:

    I just installed IDEA 13 today and tried to import several existing SBT projects. It appears to import successfully, but can’t resolve any symbols from the scala library. When I look at the scala facet it says “SBT: scala-compiler:2.10.3 [not found]” under Compiler Library.

    Just to be sure I deleted all the IDEA files in the directory and reimported again from scratch. The same thing happened.

    Any idea what’s going on?

    • Dave says:

      Yep, totally broken. Hope I can get my projects moved back to v12… ugh.

    • Viktor says:

      +1

      Trying to run make I just get:

      scala: Сompiler library for module 4bodyandmind not found: Project / SBT: scala-compiler:2.10.2

      or:
      scala: Сompiler library for module 4bodyandmind not found: Project / SBT: scala-compiler:2.10.1

      Invalidate caches doesn’t help.

      • Viktor says:

        In root .iml:

        ->

        This doesn’t seem like a corner case. Does IDEA 13 and SBT work for _anyone_?

        • Viktor says:

          Nice, my xml got removed by this “smart” blog tool.

          option name=”compilerLibraryName” value=”SBT: scala-compiler:2.10.2″
          ->
          option name=”compilerLibraryName” value=”SBT: SBT: scala-compiler:2.10.2″

  10. Jerry Kuch says:

    Me as well… trying to load an IDEA 12 project, originally produced with the gen-idea task from SBT, into IDEA 13 gave me the symptoms above, namely failure to resolve any Scala library symbols.

    Moving back to IDEA 12, the project then failed to load there…

    I’ll come back to it tomorrow and see if I can import a vanilla SBT project from scratch into IntelliJ 13 using only IDEA’s importing functionality…

    To summarize though, have any of you seen it work so far?

    I probably shouldn’t have upgraded so hastily…

  11. Andrew Gustafson says:

    The SBT library issue is definitely a bug and users shouldn’t be forced to invalidate caches. The issue is at: http://youtrack.jetbrains.com/issue/SCL-6320. Current workaround is to simply name the libraby named “SBT: SBT: scala-compiler:2.10.x” to “SBT: scala-compiler:2.10.x” which can be done when viewing modules, rather than modifying any xml.

  12. Dave says:

    Seems that resetting the compiler library in the scala facet to the SBT:SBT: one does help the compile error, but it appears that flushing the caches resets this back to the broken state. Makes it kinda hard to apply all the required hacks to make v13 useable.

    A list of required hacks in the required orders would be helpful.

    Or, will v12 notify me via updates when a working version of 13 is available?

  13. Mav says:

    Compiler library not found for me too: run on a clean project with all the old project files removed before import. Tried cleaning cache and restarting after library name change from SBT:SBT: … to SBT:.., everything staid same.

    c’mon, we’ve been waiting for proper sbt support in IDEA for so long, Scala community is gaining fast – it’s an incredible language which makes the work so much more productive. Jetbrains should recognize the opportunity to be the leading Scala IDE and put more effort into developing stable plugins for it.

  14. Caoilte O'Connor says:

    Hi Guys,
    I just imported a project I was using sbt-idea for (after deleting previous project files) and its working great so far. I even started a REPL and played around there for a bit. Running tests also feels more snappy than it used to.

    My current IntelliJ12 workflow is to run SBT in the console, which mostly means all compilations end up happening twice (once for SBT one for the so-so IDE syntax highlighting). I have to do this for when I want to run specific SBT plugins (eg revolver, assembly).

    Is there any way or are there any plans to allow me to start an SBT console from within the IDE in the same way I can start a Scala Console?

    I’ll probably have to fall back to the command line otherwise, which will continue to suck as compiles are bad enough only having to do them once….

    • Alexander Podkhalyuzin says:

      Yes, we have such plans to support console in our SBT support. However right now you can use third-party console implementation (see SBT plugin in plugins list).

      Best regards,
      Alexander Podkhalyuzin.

  15. Jan says:

    Every time I try to load a project I get the message that “org.jetbrains#sbt-structure;latest.integration” can not be found. I tried to install the plugin in my local repository and as it seems the plugin uses the scala version in its name but sbt looks for the plain name.

  16. Marcin says:

    Does the plugin support sub-projects builds? I was trying to migrate my project with multiple subprojects (first from Build.scala to build.sbt) but always failed with some multiple project error message (I cannot replicate in now because I get “org.jetbrains#sbt-structure;latest.integration” error).

  17. Henry says:

    I seem to be able to open existing projects just fine, but am unable to create a new Play 2 Scala project after updating to II13. Is there something I need to update in order to have this functionality available? The setup acts as if I wouldn’t have Play at all, giving me the following error:

    object index is not a member of package views.html
    Ok(views.html.index(“Your new application is ready.”))

  18. David Perez says:

    How do I enable “Autoimport” without re-creating the module?.
    I’ve forgotten to do so.

  19. David Perez says:

    If you import it mistakenly as a project, when you want a module, it’s not easy to revert it.

    I had to delete the generated project, rename the directory which contained the module, and re-import it as module again.

  20. David Perez says:

    How can I update the IDEA module build path, when I change the build.sbt file, by adding e.g. a new jar?.

  21. David Perez says:

    I answer myself, to my last questions: the SBT tasks window allows all these operations. I didn’t know it existed.

    Scala plugin suffers from lack of documentation. That’s normal in something that changes so quickly.

  22. Rob Conaway says:

    If I make a change to my build.sbt, I should see the changes in my IDEA project, correct? For example, if I add a libraryDependencies to build.sbt, then that library will show up in the module dependencies as soon as the build.sbt file is saved?

    I cannot see any evidence of auto-import. I checked the box for auto-import when I imported the project, but when I change build.sbt nothing changes in my IDEA project.

    • Alexander Podkhalyuzin says:

      In the current state you need to save file to get auto-import feature working.
      My oppinion is that manual importing is handier for now, I hope things will be changed in the future.

  23. Jakub says:

    Are there any plans to improve scala debugging ? There are a lot of limits right now that makes one think about using it at all.

    • Tomas says:

      +1 for debugger improvements! A debugger is something everyone uses, unlike Play support or SBT support, so I’d guess it should be given more attention.

      • Alexander Podkhalyuzin says:

        Progress is slow, but we always have in mind debugger improvements. That’s why it’s constantly improving.

        Best regards,
        Alexander Podkhalyuzin.

  24. DaMour says:

    Is there a way to enable auto import (build.sbt watching) for my already existing IDEA project? Is there a way to invoke the auto-import (sync by build.sbt w/ the external libraries) ad-hoc?

    • Alexander Podkhalyuzin says:

      It’s not yet implemeted. You can import again your project. Setting for auto-import in settings menu will be available in next nightly build or in next Scala plugin release around 10th January.
      Also you manually refresh SBT from toolwindow.

      Best regards,
      Alexander Podkhalyuzin.

  25. peg says:

    With the latest versions of intellij and sbt plugin, I have difficult importing an sbt project, but I end with the “Resolve Error” window and it freezes up. Tried many steps but in vain: “File -> Invalidate cache/restart”, changed SBT jar from bundled to custom jar for sbt 12.1.

    Any suggestions?

    PS: The lines below in the “Resolve Error” pop-up window.

    [info] Loading global plugins from /private/var/folders/c1/3_32xl455k11rdqg4d67ldxh0000gn/T/sbt-global-plugins5195518855896208613.tmp
    [info] Updating {file:/private/var/folders/c1/3_32xl455k11rdqg4d67ldxh0000gn/T/sbt-global-plugins5195518855896208613.tmp/}default-221665…
    [info] Resolving org.jetbrains#sbt-structure;2.0.0 …
    [info] Resolving org.scala-sbt#sbt;0.12.1 …
    [info] Resolving org.scala-sbt#main;0.12.1 …
    [info] Resolving org.scala-sbt#actions;0.12.1 …
    [info] Resolving org.scala-sbt#classpath;0.12.1 …
    [info] Resolving org.scala-sbt#launcher-interface;0.12.1 …
    [info] Resolving org.scala-lang#scala-library;2.9.2 …
    [info] Resolving org.scala-sbt#interface;0.12.1 …
    [info] Resolving org.scala-sbt#io;0.12.1 …
    [info] Resolving org.scala-sbt#control;0.12.1 …
    [info] Resolving org.scala-lang#scala-compiler;2.9.2 …
    [info] Resolving org.scala-sbt#completion;0.12.1 …
    [info] Resolving org.scala-sbt#collections;0.12.1 …
    [info] Resolving jline#jline;1.0 …
    [info] Resolving org.scala-sbt#api;0.12.1 …
    [info] Resolving org.scala-sbt#compiler-integration;0.12.1 …
    [info] Resolving org.scala-sbt#incremental-compiler;0.12.1 …
    [info] Resolving org.scala-sbt#logging;0.12.1 …
    [info] Resolving org.scala-sbt#process;0.12.1 …
    [info] Resolving org.scala-sbt#compile;0.12.1 …
    [info] Resolving org.scala-sbt#persist;0.12.1 …
    [info] Resolving org.scala-tools.sbinary#sbinary_2.9.0;0.4.0 …
    [info] Resolving org.scala-sbt#classfile;0.12.1 …
    [info] Resolving org.scala-sbt#compiler-ivy-integration;0.12.1 …
    [info] Resolving org.scala-sbt#ivy;0.12.1 …
    [info] Resolving org.apache.ivy#ivy;2.3.0-rc1 …
    [info] Resolving com.jcraft#jsch;0.1.46 …
    [info] Resolving commons-httpclient#commons-httpclient;3.1 …

    • Andy MacKinlay says:

      I had a similar problem. Was your error dialog truncated because it took up more than one screen? I had that problem. There was a resolve error lower down, which I was able to find out by accessing the system log (Console.app on OS X; not sure on other systems).

      • peg says:

        Yes.

        I compiled using sbt outside the idea and identified the library causing the resolve error, fixed it and then reimported into idea.

        sbt plugin is very finicky and would have appreciated identifying the error after the import to be fixed from within.

        • Andy MacKinlay says:

          Yep, I agree that allowing imports when SBT deps do not completely resolve would be very useful (as would readable error messages – that should be a very easy fix)

  26. Andy MacKinlay says:

    Is there a way to configure the global SBT settings? In particular, I need to make it look at my local Maven repository. I achieve this with vanilla SBT by adding the following line to ~/.sbt/global.sbt:

    resolvers += “Local Maven Repository” at “file://” + Path.userHome.absolutePath + “/.m2/repository”

    Can I do something equivalent with the Idea SBT? Without this I can’t import my project as it fails at the import stage (it would be great if it was possible to import anyway in these cases, BTW)

    • Alexander Podkhalyuzin says:

      No, it’s limitation of current implementation of SBT support. Most probably it will be implemented in future.

      Best regards,
      Alexander Podkhalyuzin.

  27. Davi says:

    The dependencies in build.sbt are synchronized correctly with IDEA, but the lib folder and its jars is ignored.

  28. Chuck says:

    I am done with intellij. Over to the typesafe IDE

    8:43:01 PM SBT ‘xxxx’ project refresh failed:
    Premature end of file.
    SBT settings

  29. How do I enable auto-import after the project is already created? Synchronize doesn’t seem to get new dependencies just added to build.sbt.

  30. Stephen Boesch says:

    Does not work. I started with an already-working sbt project. Followed the instructions. IJ spent along time refreshing the sbt project. But then the third party library dependencies were not resolved .

    I am going to try the gen-idea plugin.

  31. Nikita Firsin says:

    I am unable to create simplest Scala program with IntelliJ. Tried to use SBT and it ended not being able to download some tangled file reference for IVY (Connection timed out: connect url=http://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml).

    There is no clue why, I can’t find any configs for SBT and stuff. I strongly suspect Proxy configuration but can’t prove it.

    Besides, current SBT version doesn’t support non-ASCII names in paths. I can change it in manually installed SBT package, but not in IDEA-bundled one. All in all it is a frustrating experience, trying to do simplest of things and being forced to fight through the unneccessary complications.

    Offtopic: using pure Scala module to create a worksheet grants me “Error:bad macro impl binding: versionFormat is supposed to be there” error.

    Going to try Eclipse-based Scala IDE and see if I have some luck with this.

  32. Rams jerseys china Only Review

  33. b0c1 says:

    Hi guys, maybe I’m do something wrong, I have scala project files under the “project” directory (sry I hate .sbt files) but the new embedded sbt plugin will kill the project. All dependency (Build, scala etc) is marked to red. What I miss?
    The original project generated with gen-idea. this is a multilevel/multi module project… (with some web project)

  34. My relatives all the time say that I am killing my time here at web, except I
    kow I am getting know-how everyday by reading such pleasant posts.

  35. Wonderful site you have here but I was wondering if you knew of any community forums
    that cover the same topics discussed here? I’d really love to be a part of online community where I can get feed-back from other knowledgeable people that share the same
    interest. If you have any recommendations, please let me know.
    Bless you!

  36. obat kuat says:

    Hello terrific blog! Does running a blog like this take a great
    deal of work? I’ve absolutely no knowledge
    of programming but I was hoping to start my own blog soon. Anyway, should you have any suggestions or techniques
    for new blog owners please share. I understand this is off subject
    however I simply needed to ask. Many thanks!

  37. Google says:

    What’s up, everything is going perfectly here and
    ofcourse every one is sharing information, that’s truly good, keep up writing.

    Here is my web page Google

  38. What is the main advantage of your product or service and why should
    somebody buy it instead of one from somebody else.
    These are some of the major reason why it used in thee internet marketing.
    Define whyat your business is, what your products and services are and what groups of customers are going to
    be targeted by your business or by the specific
    products and services you will be selling.

    my websjte … Deerfield Beach Seo

  39. Have you ever thought about adding a little bit more than just
    your articles? I mean, what you say is valuable and everything.
    However think of if you added some great images or videos to give your posts more, “pop”!
    Your content is excellent but with pics and
    videos, this site could certainly be one of the very best in its niche.

    Wonderful blog!

    Review my website google.com – http://google.com -

  40. post1092094 says:

    I do not know if it’s just me or if everyone else experiencing issues with your
    site. It appears as if some of the written text on your posts are running off
    the screen. Can somebody else please provide feedback and let me know if this is happening to them too?
    This may be a problem with my browser because I’ve
    had this happen previously. Thanks

  41. Steffen says:

    While property prices in Canadda have steadily increased since they dipped due to the recession in 2008, there are definitely
    some good deals to be found. No one but Bill
    Gates hass that much available money. This iss an easy waay to get started—take one mrketing strategy, learn and hone it.

    Here is my web blog; small business banking (Steffen)

  42. hello there and thank you for your informationn – I have
    definitely picked uup something new ffrom right here.
    I did however expertise several technical issues using this web site, as I experienced to reload the website
    a lot of times previous to I could get it to load correctly.
    I had been wwondering iff your hosting is OK? Not that I am complaining, but sluggish loading instances times will sometimes
    affect your placement in google and could damjage your high-quality score if advertising and martketing with Adwords.
    Anyway I am adding this RSS to my email and could look out for a lot more of your respective exxiting content.
    Ensure that you update this again very soon.

  43. Or, perhaps you’re one of those students who desires a challenge, or even a good
    addition to your résumé for Grad school. Without enough traffic, you will never have enough customers and this means you
    won’t be making enough money. What you give away doesn’t have to be
    costly, but it must be valuable.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">