简体   繁体   English

将Java项目添加到rcp插件的类路径中

[英]Add a java project into an rcp plugin's classpath

I have a java project and imported plug-in in my workspace and I'd like to add the project to plug-in's classpath. 我在工作区中有一个Java项目和导入的插件,我想将该项目添加到插件的类路径中。 I know that it's possible by exporting the project to jar file and then importing it in plug-in's manifest, but when I make a change in project I have to export it again. 我知道可以通过将项目导出到jar文件,然后将其导入插件的清单中来实现,但是当我在项目中进行更改时,必须再次将其导出。 Is there a way to add java project instead of jar file to the plug-in's classpath? 有没有一种方法可以将Java项目而不是jar文件添加到插件的类路径中?

Your Eclipse IDE does resolve two kinds of plugins/fragments/features: 您的Eclipse IDE确实可以解决两种插件/片段/功能:

  1. Those located in your workspace and 那些位于您的工作区中
  2. those you have in your target platform 您在目标平台中拥有的

The plugins in your target platform are usually the one which come along as a JAR (expanded is also possible). 目标平台中的插件通常是随JAR一起提供的插件(也可以扩展)。

To add your java project as a dependency of your plugin, you have to change the project to be a plugin by adding META-INF/MANIFEST.MF to the root of your project. 要将Java项目添加为插件的依赖项,必须通过将META-INF/MANIFEST.MF添加到项目的根目录来将项目更改为插件。

Content could be as follows: 内容可能如下:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyBundleName
Bundle-SymbolicName: com.example.mybundlename
Bundle-Version: 1.0.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

As a plus you should export the packages with your API-classes 另外,您应该使用API​​类导出软件包

Export-Package: com.example.mypackage

Finally you have to define the enhanced java project as a dependency in your plugin. 最后,您必须将增强的Java项目定义为插件中的依赖项。 Open META-INF/MANIFEST.MF of your plugin edit "Required Plugins" in Tab "Dependencies". 打开插件的META-INF/MANIFEST.MF ,在“依赖项”选项卡中编辑“必需的插件”。


Update: 更新:

You can add class folders to the classpath of your plugin. 您可以将类文件夹添加到插件的类路径中。 To do so open the properties of your plugin (rightclick plugin > 'Properties'), choose 'Java Build Path', 'Add Class Folder...' and add the folder(s) which contain(s) your classes (eg 'bin'). 为此,请打开插件的属性(右键单击插件>“属性”),选择“ Java构建路径”,“添加类文件夹...”,然后添加包含您的类的文件夹(例如“ bin')。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM