The Scala Eclipse plugin page says: * Support for Eclipse plugin and OSGi development including hyperlinking to Scala source from plugin.xml and manifest files.
Scala Eclipse插件页面说:*支持Eclipse插件和OSGi开发,包括从plugin.xml和清单文件超链接到Scala源代码。
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?
这种支持如何运作?制作Scala插件没有向导。我没有找到关于如何在Eclipse插件/ RCP应用程序中使用Scala的文档。它甚至可能吗?
7 个解决方案
#1
Yes, it is possible. In fact, the Scala Eclipse plugin itself is written in Scala.
对的,这是可能的。实际上,Scala Eclipse插件本身是用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.
我自己从未创建过Scala RCP应用程序,但我猜你需要做的是使用你选择的向导正常创建项目。项目进入工作区后,右键单击并选择“添加Scala自然”(或其他类似的效果)。结果将是一个Scala项目,其中包含RCP应用程序的所有常规陷阱。在这些设置步骤之后,您应该能够在项目中使用Java和Scala。
#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.
我可以说我已经使用scala 2.8.0 beta版成功创建了一个Scala RCP应用程序。这些改进值得注意。我按照这里描述的步骤。这比我最初的想法容易。
For good measure I then translated the Java code to Scala ... one file at a time.
为了更好的衡量,我然后将Java代码翻译成Scala ...一次一个文件。
#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.
在Scala中编写的插件代码不能与RCP一起使用的原因很简单,即在构建插件jar时不会导出.class文件。但是您可以使用一种解决方法:使用Plug-In Manifest Editor打开plugin.xml,选择Runtime选项卡并为类路径添加新条目“bin”。然后在“构建”选项卡上的“二进制构建”树中,选择bin文件夹。然后,在导出产品时,将在工作空间中编译的类文件导出到插件jar中。
#4
This tutorial should be of help:
本教程应该有所帮助:
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.)
将Scala Nature添加到插件项目后,不要忘记在插件的依赖项中包含scala.library(并更新相应的运行和产品配置)! (另外,如果在添加Scala Nature时在构建路径中出现另一个JRE系统库,则可以安全地将其删除以避免RequiredExecutionEnvironment警告。)
#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:
有没有人让它作为实际出口产品工作?我很高兴开发我的scala插件,它在Eclipse中运行得很好,但是当我尝试导出产品时,构建过程失败,说它无法将我的scala对象解析为类型。我发现了这个bug报告:
#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.
Scala Nature调用JDT编译器并使Scala编译器可以使用Java类。我遇到了一个问题,我启用了Scala Nature和Java Nature。确保您没有启用Java Nature。
#1
Yes, it is possible. In fact, the Scala Eclipse plugin itself is written in Scala.
对的,这是可能的。实际上,Scala Eclipse插件本身是用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.
我自己从未创建过Scala RCP应用程序,但我猜你需要做的是使用你选择的向导正常创建项目。项目进入工作区后,右键单击并选择“添加Scala自然”(或其他类似的效果)。结果将是一个Scala项目,其中包含RCP应用程序的所有常规陷阱。在这些设置步骤之后,您应该能够在项目中使用Java和Scala。
#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.
我可以说我已经使用scala 2.8.0 beta版成功创建了一个Scala RCP应用程序。这些改进值得注意。我按照这里描述的步骤。这比我最初的想法容易。
For good measure I then translated the Java code to Scala ... one file at a time.
为了更好的衡量,我然后将Java代码翻译成Scala ...一次一个文件。
#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.
在Scala中编写的插件代码不能与RCP一起使用的原因很简单,即在构建插件jar时不会导出.class文件。但是您可以使用一种解决方法:使用Plug-In Manifest Editor打开plugin.xml,选择Runtime选项卡并为类路径添加新条目“bin”。然后在“构建”选项卡上的“二进制构建”树中,选择bin文件夹。然后,在导出产品时,将在工作空间中编译的类文件导出到插件jar中。
#4
This tutorial should be of help:
本教程应该有所帮助:
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.)
将Scala Nature添加到插件项目后,不要忘记在插件的依赖项中包含scala.library(并更新相应的运行和产品配置)! (另外,如果在添加Scala Nature时在构建路径中出现另一个JRE系统库,则可以安全地将其删除以避免RequiredExecutionEnvironment警告。)
#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:
有没有人让它作为实际出口产品工作?我很高兴开发我的scala插件,它在Eclipse中运行得很好,但是当我尝试导出产品时,构建过程失败,说它无法将我的scala对象解析为类型。我发现了这个bug报告:
#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.
Scala Nature调用JDT编译器并使Scala编译器可以使用Java类。我遇到了一个问题,我启用了Scala Nature和Java Nature。确保您没有启用Java Nature。