views:

337

answers:

2

Hi,

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

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

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

Thanks in advance!

A: 

Hi!

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.

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.

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?

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

Hope this helps, Vlad

Vlad Dumitrescu
A: 

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.

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)

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.

Is there another way of doing this?