4

Note: This is an exact repost of the same question on the Scala-IDE mailing list, where I got zero reply and gave up waiting after 5 days.

I'm writing a Scala Compiler Plugin. It's currently called scalawrapper (but I might find a better name later). I have the Typesafe Stack installed, and I put my plugin in it under:

C:\Program Files\typesafe-stack\misc\scala-devel\plugins

Now I can call scalac like this:

scalac -classpath ... -Xplugin-require:scalawrapper test\...

and it finds and uses my plugin automatically.

Unfortunately, I just can't get the Scala-IDE to use it. I always get Missing required plugin: scalawrapper. In the "Project Properties \Scala Compiler (Use Project Settings)\Advanced" tab, I have entered scalawrapper in the Xplugin-require field, and that works, since I get the error. But nothing I can type in Xpluginsdir seem to have any effect.

I have tried the absolute path given above, have tried with forward and backward slashes, have tried a temporary directory without spaces in it, have tried relative to project directory, have tried relative to workspace. It just will not use anything. I should also note that is is not specific to my own plugin, as I tried to use the ScalaCL plugin before in a previous version of the Scala-IDE, and failed for the exact same reason.

I have just updated today (15.10.2011) and so should have the latest version (it seems I can finally explicitly set the indentation to 4, but maybe I just overlooked the setting in the past).

Can someone tell me what it actually expects, and what is uses as default when I don't put anything in Xpluginsdir?

Matthew Farwell
  • 60,889
  • 18
  • 128
  • 171
Sebastien Diot
  • 7,183
  • 6
  • 43
  • 85

1 Answers1

3

The Scala IDE uses the presentation compiler, not the compiler that you've installed. To use a plugin, with Scala IDE, you need to specify it in the preferences in Eclipse.

Try Windows->Preferences->Scala->Compiler. See the Advanced tab. The paths are relative to the workspace.

EDIT: When I say relative to the workspace, I mean the actual workspace directory under which the .metadata is stored ($workspace_loc). I have a project where project files including the source code is stored in one directory and the workspace is elsewhere, i.e the $project_loc (c:\code\project\source) is different from the $workspace_loc (c:\code\project\workspace). The directory that you specify in the compiler parameters is relative to the workspace ($workspace_loc).

To find out if you have a similar setup, go to the project and select Properties->Resource->Linked Resources.

I created a directory under $workspace_loc called plugin and placed the jar file in there. Under Windows->Preferences->Scala->Compiler Advanced tab I have

Xplugin = C:\code\project\workspace\plugin\xxx-0.0.1.jar
Xplugin-require = xxx

Please note that you can specify the plugin in the project properties as well, but it still uses $workspace_loc. The above configuration works for me.

Matthew Farwell
  • 60,889
  • 18
  • 128
  • 171
  • You have not read my question. I know where the setting is: "In the "Project Properties \Scala Compiler (Use Project Settings)\Advanced" tab," The only problem is, that IT DOESN'T WORK. – Sebastien Diot Oct 21 '11 at 16:52
  • Sorry, I did read your question, but I wasn't explicit enough about what I meant. I've edited the answer. – Matthew Farwell Oct 21 '11 at 20:19
  • Thanks. If I do it exactly like you said, it seems to work. I think the reason I thought it did not work before was that Eclipse throws away all output (both System.out and log(...)), so it looks like it did nothing. The same options that produce the output with scalac do nothing in Eclipse. I had to throw an exception to prove that it works, but that's a different problem to be solved in a different question. Have you ever found out how to use Xpluginsdir so that you don't have to specify the jar explicitly? – Sebastien Diot Oct 22 '11 at 08:49