16

Using IntelliJIdea 12, i downloaded the Scala plugin and created a HelloWorld application.

The following import seems odd. Why does IDEA not recognize this to be a Scala Application? Is my setup incomplete?

enter image description here

I checked to see where does my compiler points to and got this. Don't really see a way to navigate IDEA to my scala installation.

Please advise.

enter image description here

James Raitsev
  • 92,517
  • 154
  • 335
  • 470

3 Answers3

16

When creating a new Scala project from the wizard IDEA can download and configure everything for you:

New Scala Project

Settings can be changed later in the Scala Facet:

facet

and in Compiler:

compiler

Libraries configuration:

compiler

scala

Code and imports completion is available from the Scala library:

completion

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 1
    I tried downloading scala 2.9.2 and 2.10 from the Scala Module. It downloads a .tgz but i get an error `Error while downloading Scala: error in opening zip file` – nicerobot Dec 07 '12 at 01:31
  • I have installed scala 2.9.2 using homebrew but IntelliJ doesn't recognize it as a scala home when i point it to the Cellar. – nicerobot Dec 07 '12 at 01:36
  • Downloading 2.9.2 and the docs manually i still get `no /doc/scala-devel-docs/api` presumably because `scala-docs-2.9.2.tgz` extracts to `scala-docs-2.9.2` and not within `scala-2.9.2`. I suppose no one tested this on a Mac?! – nicerobot Dec 07 '12 at 01:49
  • 1
    @nicerobot, `brew` installation uses non-standard layout, you need to specify the `/libexec` subdirectory. See [this answer](http://stackoverflow.com/a/10828320/104891) for for the Mac specific instructions. – CrazyCoder Dec 07 '12 at 02:00
  • @CrazyCoder Thanks. Worked. My bad for not noticing `libexec/`. Any thoughts on the other two issues above? – nicerobot Dec 07 '12 at 19:51
  • @nicerobot, solution for the documentation is also linked in the same comment, as for the download problem, you are welcome to report it ay http://youtrack.jetbrains.net/issues/SCL. – CrazyCoder Dec 07 '12 at 20:32
  • Nice job, just for completeness, relevant basic resource -http://tv.jetbrains.net/videocontent/get-started-with-scala-in-intellij-idea –  Apr 08 '13 at 11:05
5

You need to add Scala as a framework for your project.

To do this, right click on the top level directory in your project, choose "Add Framework Support..." and select Scala. Then Scala will be added as a "Facet" of your project.

Here is a good page with more info:

sourcedelica
  • 23,940
  • 7
  • 66
  • 74
  • 5
    I don't have Scala listed in the list of Frameworks when i do that. How does one add it? Do you have it in the list? Please include screenshot – James Raitsev Dec 05 '12 at 13:10
  • It should be there as long as you have the Scala plugin enabled. Looks like you got a nice answer from @CrazyCoder for getting a new project set up. – sourcedelica Dec 06 '12 at 03:41
  • 3
    I also do not have scala listed as a framework (bash and jruby and maven only) even though scala plugin is included. – WestCoastProjects Aug 15 '13 at 21:37
  • It seems that this has been recently changed. I'm running 0.19.299 against IDEA 12 and don't see this option. – Andy V Sep 18 '13 at 22:50
  • 1
    It's probably because Scala is already a facet for your project (check your project settings). I'm running the same plugin version and I'm getting this option for my pure Java projects. – sourcedelica Sep 19 '13 at 14:28
2

I got around this by downloading the Scala library from scala-lang.org, unzipping it and then pointing the project to it. It worked fine after that. But of course, I'm an eclipse guy so perhaps someone else might be able to give you a better automated (?) solution. Here's what my project looks like in Module Settings -> Libraries:

enter image description here

Plasty Grove
  • 2,807
  • 5
  • 31
  • 42