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):

About Pavel Fatin

IntelliJ Scala plugin developer (http://pavelfatin.com)
This entry was posted in Uncategorized. Bookmark the permalink.

5 Responses to Project configuration explained

  1. Alain O'Dea says:

    The Maven import is easily the best way to get a project started for the Scala Plugin IMHO.

    For those not using Maven, this is useful. I followed these directions and successfully got an existing large-scale multi-module Java project to work with the plugin.

    The project settings are also portable, which makes team development much easier. Kudos :)

  2. Adrian says:

    Extremely useful. Thanks.

  3. Moritz says:

    Thanks for the writeup! Very helpful! The manual configuration/creation of the scala-compiler library was not that intuitive

  4. melgart says:

    these directions are still good for getting Intellij 10.5 and scala 2.9.2 working. thank you OP.

  5. Vlad Patryshev says:

    what am I doing wrong?
    I have scala-compiler.jar, scala-library.jar in one library, but the compiler does not see it

    intellij 123.123

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> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>