Scala logo

Scala Plugin

Scala Plugin for IntelliJ IDEA and Android Studio

News

Project configuration explained

Although the work on new Scala project configuration is still in progress, a brief clarification may come in handy.

  • A module that requires compiling with Scalac should have a Scala facet attached.
  • Facet refers to “Compiler library” which is used to instantiate Scalac inside JVM (the library provides “compiler classpath” that is completely separated from “project classpath”)
    Compiler library (usually) should include scala-compiler*.jar and scala-library*.jar.
    For special purposes, compiler library may include directories (like “/build/classes/”, etc), in that case, no library validation is performed.
  • Facet holds custom compiler options and a list of Scalac plugins (relative paths allowed).
  • As usual, modules that use Scala standard library should include it in module dependencies.
  • Both compiler library and standard library may be created using build-in wizard (from Scala distribution).
  • Plugins doesn’t include bundled Scalac anymore.
  • Maven projects can be imported automatically.

To create a new project that uses Scala:

  1. In “New Project” wizard check “Scala” in technologies list.
  2. Provide a path to Scala installation (if not detected)

To add a new module that uses Scala into existing project:

  1. In “Add Module” wizard check “Scala” in technologies list.
  2. Provide a path to Scala installation (if not detected)

To add Scala support to existing module:

  1. Right-click the module in Project View, choose “Add Framework Support…”
  2. Check “Scala” in technologies list (unavailable if module has Scala facet attached)
  3. Provide a path to Scala installation (if not detected)

To manually configure existing module:

  1. Create library “scala-compiler”:
    Classes: scala-compiler.jar; scala-library.jar
  2. Create library “scala-library”:
    Classes: scala-dbc.jar; scala-library.jar; scala-swing.jar
    Sources: scala-dbc-src.jar; library-src.jar; swing-src.jar
    Docs: /doc/scala-devel-docs/api/
    (if you downloaded Scala as an archive, you need to get separate API docs archive and extract it so that <scala home>\doc\scala-devel-docs\api exist; if you installed Scala using LzPack, then API docs are already there)
  3. Add Scala facet to the module, select “scala-compiler” library as compiler library
  4. Add “scala-library” to module dependencies.

Hints:

  • Don’t add Scala compiler library to module dependencies (unless you really need Scala compiler classes in your code)
  • Don’t forget to attach “scala-library*.jar” to Scala compiler library, it’s a dependency of “scala-compiler*.jar” itself.

Screenshots

Scala support for existing module:

Wizard (on new project, on new module, after “Add Framework Support…”):

Libraries:

Standard library:

Compiler library:

Module dependencies:

Facet settings:

Advanced facet settings:

Autocompletion (Scala standard library):

Documentation lookup (Scala standard library API docs):

Definition lookup (Scala standard library sources):