问题
The Scala Eclipse plugin page says: * Support for Eclipse plugin and OSGi development including hyperlinking to Scala source from plugin.xml and manifest files.
How does this support work? There's no wizards for making Scala plugins. I've found no documentation on how to use Scala in a Eclipse plugin/RCP application. Is it even possible?
回答1:
Yes, it is possible. In fact, the Scala Eclipse plugin itself is written in Scala.
I've never created a Scala RCP app myself, but I'm guessing that what you need to do is create the project normally using your wizard of choice. Once the project is in your workspace, right-click and select "Add Scala Nature" (or something to that effect). The result will be a Scala project with all of the regular trappings of an RCP app. You should be able to use both Java and Scala within the project after these setup steps.
回答2:
This is an old question; but an update may be helpful to someone.
I can say that I have successfully created a Scala RCP application using the scala 2.8.0 beta release. The improvements are notable. I followed the steps described here. It was easier than I initially thought.
For good measure I then translated the Java code to Scala ... one file at a time.
回答3:
The reason the plugin code written in Scala doesn't work with RCP is simply that the .class files don't get exported when the plugin jar is built. But there is a workaround you can use: Open the plugin.xml with the Plug-In Manifest Editor, select the Runtime tab and add a new entry "bin" for the classpath. Then on the Build tab, in the Binary Build tree, select the bin folder. The class files that are compiled in the workspace are then exported into the plug-in jar when you export the product.
回答4:
This tutorial should be of help:
http://www.coconut-palm-software.com/the_new_visual_editor/doku.php?id=blog:using_scala_to_create_eclipse_rcp_applications
I tried it out and it worked for me.
回答5:
After adding Scala Nature to the plug-in project, don't forget to include scala.library among the dependencies of your plugin (and update the corresponding run and product configuration)! (Additionally, if another JRE system library appears in the build path when adding Scala Nature, you can safely remove it to avoid the RequiredExecutionEnvironment warning.)
回答6:
Did anyone get it to work as an actual exported product? I was happily developing my scala plugin and it was running great inside Eclipse, but when I tried to export the product, the build process failed saying it couldn't resolve my scala object to a type. I found this bug report:
http://lampsvn.epfl.ch/trac/scala/ticket/1919
回答7:
The Scala Nature invokes the JDT compiler and makes the Java classes available tot he Scala compiler. I was having an issue where I have both the Scala Nature and Java Nature enabled. Make sure you don't have the Java Nature enabled.
来源:https://stackoverflow.com/questions/446389/how-to-write-eclipse-rcp-applications-with-scala