INFO: Building the Scala plugin within IDEA

I've just managed to get the Scala plugin to build with IDEA itself. As it's not obvious, I thought I'd document it for anyone else attempting to do it.

Prerequisites:

  1. Download and install a current IDEA EAP or CE. (I used Maia CE 90.06 from http://www.jetbrains.org/display/IJOS/Download)
  2. Download and install a Scala 2.8.0 binary installation. (I used the latest from http://www.scala-lang.org/node/212/distributions)
  3. Download and install Ant (from http://ant.apache.org/)


Before setting up IDEA, check that it builds with ant:

Building from ant:

  1. Check out the plugin source from git: $ git clone git://git.jetbrains.org/idea/scala-plugin.git
  2. Edit scala.properties in the checked out root directory, setting the following:
    1. idea.home=<IDEA home dir>. e.g. on OS X: /Applications/Maia-IC-90.96.app
    2. jdk.home=<JDK home dir>. e.g. on OS X: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
    3. scala.lib=<Scala lib dir>. Must be a 2.8.0 distribution (as per above). e.g. on OS X: /Users/andrew/dev/scala/scala-2.8.0.r19155-b20091020023404/lib
    4. build.number=<Some number>. Not sure if it has to be in any range, I just picked something close to the current release
  3. Build the plugin using Ant: $ ant


That should build the plugin. The dist directory will contain  two .zip-archives. The binary plugin is the one you can install. e.g. scala-intellij-bin-0.3.xx.zip

Installing in IDEA:

  1. Unzip the content of *-bin.zip to the appropriate IntelliJ plugin directory: (Replace IntelliJIdea90CE with the correct version of IDEA you are using)
    1. Windows: $USER_HOME/.IntelliJIdea90CE/config/plugins
    2. Linux: ~/.IntelliJIdea90CE/config/plugins
    3. Mac: ~/Library/Application\ Support/IntelliJIdea90CE/
  2. Restart IDEA


This is optional, but is a good way to explore the plugin.


Building within IDEA:

  1. Open the project file in the plugin root directory (Scala.ipr)
  2. Go to the Project Structure (File -> Project Structure)
    1. Click on "Project" in the left panel and change the Project SDK.
      Click on "New" and select "IntelliJ IDEA SDK".
      Select the home directory of the IDEA installation. e.g.  /Applications/Maia-IC-90.96.app
      Select a 1.6 JDK to use within it
    2. Edit the newly created SDK. (Click "Edit"). Add the following .jar files from the IDEA installation:
      lib/idea.jar
      plugins/maven/lib/maven.jar
    3. Click on "Global Libraries" in the left panel to define a "Scala SDK" library:
      Click the plus button to add a new library (make sure you call it "Scala SDK").
      Apply it to all modules in the project (it should replace the existing undefined one)
      Add the following .jar files from the scala distribution: scala-compiler.jar, scala-library.jar and scalap.jar
    4. Click OK, to apply the Project Structure changes


You should now be able to build the plugin with IDEA, using Make and Build from the Build menu.

TODO:

  1. Running tests: Right-clicking on tests and attempting to run them doesn't work. I suspect it is probably due to missing .jar files that need to be added to the IDEA SDK definition.


Anyway, I hope this helps others who are curious to explore/hack the Scala plugin. Hopefully an official guide will be out soon from the IntelliJ guys (hint, hint :-))

Cheers,
Andrew

0

Ok, thank you for your cues:)
I hope, we'll do it soon. Also I hope for good hacks after this posts, we will glad for any help.

Best regards,
Alexander Podkhalyuzin.

0
Avatar
Permanently deleted user

IDEA SDK
Add all jars from within $IDEA_HOME/plugins/maven and $IDEA_HOME/plugins/properties.
(Optional) Check out IDEA sources (git clone git://git.jetbrains.org/idea/community.git idea) and add  source paths to the IDEA SDK definitions. I had to select idea/plugins, idea/platform, and idea/java. IntelliJ scanned and found the various source roots under these.

Edit plugin.xml:

replace:

  <idea-version since-build="SINCE_IDEA" until-build="UNTIL_IDEA"/>

with:
  <idea-version since-build="90.94" until-build="90.96"/>

And edit TestUtils.getTestDataPath

replace:
        TEST_DATA_PATH = "/Users/jason/code/scala-idea-plugin/testdata";
with:
        TEST_DATA_PATH = new File(".", "testdata").getAbsolutePath()

-jason

0

请先登录再写评论。