How to get Scala Compiler Plugin to work in Scala IDE

≯℡__Kan透↙ 提交于 2020-01-02 05:30:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7848521/how-to-get-scala-compiler-plugin-to-work-in-scala-ide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!