如何将我的片段添加到现有插件的required-plugins列表中

时间:2022-10-31 22:56:16

I currently have an existing plugin, which references a class from a required plugin. I have replaced this code with a reference to a class which is part of my fragment.

我目前有一个现有的插件,它引用了一个必需插件的类。我已经用对类片的引用替换了这段代码,这是我片段的一部分。

I am facing two issues. If I import my fragment as a jar file, I am not able to see the changes I have made as the plugin running as an eclipse application results in a ClassNotFoundException

我面临两个问题。如果我将我的片段作为jar文件导入,我无法看到我在插件运行时所做的更改,因为eclipse应用程序会导致ClassNotFoundException

To overcome this, I link an additional source (of fragment) to the existing plugin project. However, the link uses an absolute path, and makes it unfit for deployment.

为了解决这个问题,我将一个额外的源代码(片段)链接到现有的插件项目。但是,该链接使用绝对路径,并使其不适合部署。

I want to be able to package the plugin with the code modification and be able to "depend" on my fragment code. Is there a way I can add my fragment as a dependency?

我希望能够通过代码修改打包插件,并能够“依赖”我的片段代码。有没有办法可以将我的片段添加为依赖?

For example:

Plugin Project I am changing : org.eclipse.*.editor
it depends on org.eclipse.*.edit

I have a fragment mydomain.*.edit which has org.eclipse.*.edit as host plugin

I want org.eclipse.*.editor to pick up mydomain.*.edit 
instead of org.eclipse.*.edit

ps: I have also tried packaging the jar file for the mydomain.*.edit in the plugins directory and try and pick it up from there, it doesnt show up on the list when I click add required plugins on the dependency tab on the plugin.xml file of the org.eclipse.*.editor

ps:我也尝试打包mydomain的jar文件。*。在plugins目录中编辑并尝试从那里拿起它,当我在插件的依赖选项卡上单击添加所需的插件时,它不会显示在列表中org.eclipse。*。编辑器的.xml文件

Please let me know if I am not clear enough, I will try and rephrase it.

如果我不够清楚,请告诉我,我会尝试改写它。

Thanks in advance!

提前致谢!

2 个解决方案

#1


If I understand correctly what you want to do, I don't think that it's possible. You will have to try some other way.

如果我理解你想做什么,我认为这是不可能的。你将不得不尝试其他方式。

Plugins have dependencies on other plugins. Fragments don't exist as separate runtime entities, but only as extensions of a plugin. So your plugin can only refer to the 'editor' plugin.

插件依赖于其他插件。片段不作为单独的运行时实体存在,而仅作为插件的扩展。所以你的插件只能引用'编辑'插件。

Classes provided by a fragment can't (and shouldn't) be accessed directly. They can be returned by the original plugin (A) if they are implementing an executable extension provided by plugin A.

片段提供的类不能(也不应该)直接访问。如果它们实现了插件A提供的可执行扩展,它们可以由原始插件(A)返回。

If you refer to the fragment's code from another plugin (B), the classes will be loaded by plugin B's classloader and be different from the ones that are loaded by plugin A.

如果从另一个插件(B)引用片段的代码,那么这些类将由插件B的类加载器加载,并且与插件A加载的类不同。

What is the purpose of your fragment? Do you want to get access to internal code in plugin A? Do you want to extend an eclipse editor?

你片段的目的是什么?您想要访问插件A中的内部代码吗?你想扩展一个eclipse编辑器吗?

If you want to extend functionality that the original plugin is not exposing as extensible, I think the only way is to write a plugin, extend the editor class from the original plugin, register it alongside the original one and use it instead.

如果你想扩展原始插件没有暴露的功能,我认为唯一的方法是编写一个插件,从原始插件扩展编辑器类,将其与原始插件一起注册并使用它。

[Edit] Maybe this link will explain better: Eclipse FAQ

[编辑]也许这个链接会更好地解释:Eclipse FAQ

Hope this helps, Vlad

弗拉德,希望这有所帮助

#2


Thanks Vlad, Your explanation was very helpful. Unlike the extension based architecture that is truly intended for fragments, I had to modify a certain component in the editor that was not exposed as part of the extension. This modification referred to an external project I created as an fragment but could have been a normal java project packaged a jar file that I could place in the classpath of the editor.

谢谢弗拉德,你的解释非常有帮助。与真正用于片段的基于扩展的体系结构不同,我不得不修改编辑器中未作为扩展的一部分公开的某个组件。这个修改是指我作为片段创建的外部项目,但可能是一个普通的java项目打包了一个jar文件,我可以放在编辑器的类路径中。

I was able to resolve the dependency issues by placing the jar file in class path, however when I export the plugins and related plugins as jar files and place it in the dropin directory, it does not install correctly. (Nor does placing the jar files in the plugins directory)

我能够通过将jar文件放在类路径中来解决依赖性问题,但是当我将插件和相关插件作为jar文件导出并将其放在dropin目录中时,它无法正确安装。 (也没有将jar文件放在plugins目录中)

The eclipse editor that I am trying to modify uses the EMF project. I have kept the EMF project in the workspace inorder to resolve dependencies of the editor. However when I replace the EMF jar files bundled with eclipse with the one in the workspace, the files that I want to edit are not correctly recognized.

我试图修改的eclipse编辑器使用EMF项目。我已将EMF项目保留在工作区中,以便解决编辑器的依赖关系。但是,当我将eclipse捆绑的EMF jar文件替换为工作区中的文件时,我想要编辑的文件无法正确识别。

Is there another way of doing this?

还有另一种方法吗?

#1


If I understand correctly what you want to do, I don't think that it's possible. You will have to try some other way.

如果我理解你想做什么,我认为这是不可能的。你将不得不尝试其他方式。

Plugins have dependencies on other plugins. Fragments don't exist as separate runtime entities, but only as extensions of a plugin. So your plugin can only refer to the 'editor' plugin.

插件依赖于其他插件。片段不作为单独的运行时实体存在,而仅作为插件的扩展。所以你的插件只能引用'编辑'插件。

Classes provided by a fragment can't (and shouldn't) be accessed directly. They can be returned by the original plugin (A) if they are implementing an executable extension provided by plugin A.

片段提供的类不能(也不应该)直接访问。如果它们实现了插件A提供的可执行扩展,它们可以由原始插件(A)返回。

If you refer to the fragment's code from another plugin (B), the classes will be loaded by plugin B's classloader and be different from the ones that are loaded by plugin A.

如果从另一个插件(B)引用片段的代码,那么这些类将由插件B的类加载器加载,并且与插件A加载的类不同。

What is the purpose of your fragment? Do you want to get access to internal code in plugin A? Do you want to extend an eclipse editor?

你片段的目的是什么?您想要访问插件A中的内部代码吗?你想扩展一个eclipse编辑器吗?

If you want to extend functionality that the original plugin is not exposing as extensible, I think the only way is to write a plugin, extend the editor class from the original plugin, register it alongside the original one and use it instead.

如果你想扩展原始插件没有暴露的功能,我认为唯一的方法是编写一个插件,从原始插件扩展编辑器类,将其与原始插件一起注册并使用它。

[Edit] Maybe this link will explain better: Eclipse FAQ

[编辑]也许这个链接会更好地解释:Eclipse FAQ

Hope this helps, Vlad

弗拉德,希望这有所帮助

#2


Thanks Vlad, Your explanation was very helpful. Unlike the extension based architecture that is truly intended for fragments, I had to modify a certain component in the editor that was not exposed as part of the extension. This modification referred to an external project I created as an fragment but could have been a normal java project packaged a jar file that I could place in the classpath of the editor.

谢谢弗拉德,你的解释非常有帮助。与真正用于片段的基于扩展的体系结构不同,我不得不修改编辑器中未作为扩展的一部分公开的某个组件。这个修改是指我作为片段创建的外部项目,但可能是一个普通的java项目打包了一个jar文件,我可以放在编辑器的类路径中。

I was able to resolve the dependency issues by placing the jar file in class path, however when I export the plugins and related plugins as jar files and place it in the dropin directory, it does not install correctly. (Nor does placing the jar files in the plugins directory)

我能够通过将jar文件放在类路径中来解决依赖性问题,但是当我将插件和相关插件作为jar文件导出并将其放在dropin目录中时,它无法正确安装。 (也没有将jar文件放在plugins目录中)

The eclipse editor that I am trying to modify uses the EMF project. I have kept the EMF project in the workspace inorder to resolve dependencies of the editor. However when I replace the EMF jar files bundled with eclipse with the one in the workspace, the files that I want to edit are not correctly recognized.

我试图修改的eclipse编辑器使用EMF项目。我已将EMF项目保留在工作区中,以便解决编辑器的依赖关系。但是,当我将eclipse捆绑的EMF jar文件替换为工作区中的文件时,我想要编辑的文件无法正确识别。

Is there another way of doing this?

还有另一种方法吗?