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:
- Download and install a current IDEA EAP or CE. (I used Maia CE 90.06 from http://www.jetbrains.org/display/IJOS/Download)
- Download and install a Scala 2.8.0 binary installation. (I used the latest from http://www.scala-lang.org/node/212/distributions)
- Download and install Ant (from http://ant.apache.org/)
Before setting up IDEA, check that it builds with ant:
Building from ant:
- Check out the plugin source from git: $ git clone git://git.jetbrains.org/idea/scala-plugin.git
- Edit scala.properties in the checked out root directory, setting the following:
- idea.home=<IDEA home dir>. e.g. on OS X: /Applications/Maia-IC-90.96.app
- jdk.home=<JDK home dir>. e.g. on OS X: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
- 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
- build.number=<Some number>. Not sure if it has to be in any range, I just picked something close to the current release
- 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:
- Unzip the content of *-bin.zip to the appropriate IntelliJ plugin directory: (Replace IntelliJIdea90CE with the correct version of IDEA you are using)
- Windows: $USER_HOME/.IntelliJIdea90CE/config/plugins
- Linux: ~/.IntelliJIdea90CE/config/plugins
- Mac: ~/Library/Application\ Support/IntelliJIdea90CE/
- Restart IDEA
This is optional, but is a good way to explore the plugin.
Building within IDEA:
- Open the project file in the plugin root directory (Scala.ipr)
- Go to the Project Structure (File -> Project Structure)
- 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 - Edit the newly created SDK. (Click "Edit"). Add the following .jar files from the IDEA installation:
lib/idea.jar
plugins/maven/lib/maven.jar - 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 - Click OK, to apply the Project Structure changes
- Click on "Project" in the left panel and change the Project SDK.
You should now be able to build the plugin with IDEA, using Make and Build from the Build menu.
TODO:
- 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
请先登录再写评论。
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.
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