Eclipse RCP: build product able to load all plugins in plugins directory - eclipse-rcp

I need to configure my eclipse product to load all features/plugins in features/plugins directory. Now my product loads just plugins that are listed in metadata, so if I export some plugin directly from eclipse tool as "deployable plugins" it's loaded in my product, but if I put a plugin jar directly in plugins directory It doesn't appear (the same if I work with features)
I simply make new product configurations, put the feature that contains my application plugin and then exporting product I have this problem.
My eclipse version is 3.6.1
I think the problem is in the launcher configuration but I don't know what I have to change

In theory, your exported RCP application should simply pick up any new features and plugins you add later. However, make sure you put the extra stuff in the dropins folder of your RCP, since this is the expected location for manually installed features since the introduction of p2.
If for some reason it still doesn't work, try launching Eclipse with the -clean command line argument.
According to The Eclipse runtime options page, the -clean argument has the following effect:
[...] any cached data used by the OSGi framework and eclipse runtime will be wiped clean. This will clean the caches used to store bundle dependency resolution and eclipse extension registry data. Using this option will force eclipse to reinitialize these caches.
In my experience this can resolve many mysterious cases, where newly added plugins are not loaded by Equinox.

Related

Eclipse RCP plugin dependencies

I am trying to generate an RCP product from a set of Eclipse plugin. When I am trying to run the Eclipse plugin from my Eclipse.rcp.product plugin, Eclipse is asking me to add all the dependent plugins. I have done that.
However, on adding a new plugin, it starts asking for dependencies (e.g., third party libraries from Eclipse's Orbit repo) of that plugin too. All the dependencies of individual plugins are referenced in those plugins.
Why do I have to add all the references again in the RCP plugin. What is the way around or right way?
The xxx.product file must list every plugin that your RCP is going to use as this list determines what is included in the resulting product.
This is a separate list from the individual plugin dependencies.
The Dependencies tab of the .product file editor has an 'Add Required' button which should add everything that is needed (assuming you have already added all your plugins).
You can also use 'features' rather than 'plugins' for the product file which reduces the number of things that need to be included in the dependencies.

Runtime error of NoClassDefFoundError when a eclipse plugin depends on other eclipse plugin

I have an eclipse plugin project com.prosseek.asttest, and I spin off a new plugin project com.prosseek.impactAnalyzer that has one class CallHierarchyGenerator.java. Now asttest project depends on impactAnalyzer project. I had no choice but to make impactAnalyzer project eclipse plugin as it uses JDT library.
After setting up the build path in com.prosseek.asttest, it builds without a problem.
However, when I execute the plugin, I got an error missing CallHierarchyGenerator.java class.
What might be wrong?
If you are running this as an OSGI or Eclipse Application, you need to explicity export packages as available to other plugins as by default they are not. Open your manifest editor in plugin 1. Click on the runtime tab and add the packages as "Exported" then the class loader in blugin 2 will be able to find it.
Also looks like you might be doing the class path configuration wrong. in plugin 2 make sure you add plugin 1 as a dependency in the dependencies tab of the manifest editor. Looks like you are doing a dependency configuration as if it were a regular java application
Based on Duncan's answer, I could fix this issue.
Export packages in impactAnalyzer
Actually I didn't add it manually, but it's already exported, as (I guess) I did it with Quick Assist automatically.
Required Plug-ins
I had to Add com.prosseek.impactAnalyzer in the dependecies.
Run configuration update
I had one more step to do, I had to open run configuration to add required plug-ins.
Export the plugin
When exporting the asttest plugin, I also had to export impactAnalyzer also.

Eclipse 3.7 Required Plug-ins

I am currently running Eclipse 3.7 Indigo
My current project is a Plug-in Project
I wanted to try out the product called icePDF in my existing project.
So I downloaded the two required jar files from the binary download.
icepdf-core.jar and icepdf-viewer.jar
So I created a new plug-in project from existing jars. I am added the two jar files and created the plug-in project. I then exported the project and produced a project jar file .
Went back in to my existing project where I want to use the features of icePDF.
Went to dependencies -> Required Plug-ins -> Added my new icePDF plugin.
I am sure that I am missing a key step. Because as soon as I close the icePDF project in Package Explorer. I get a error in my main project.
Error : Missing Required Plug-in
What I don't understand is I have at least 12 other required plug-ins, none of them are open.
Was this the right way to try and add the icePDF jars to my existing project? Was there a way to just incorporate the jars in to the plug-in project without having to create the new project?
EDIT
Looks like icePDF primarily uses Swing. My project is SWT based, I do not want to use Swing in the project. I am looking for something that will view a existing pdf, convert a pdf and print a pdf to local printer.
Any suggestions??
It is normal behavior that Eclipse reports an error when a required plugin is closed, if this plugin is only available through your workspace. I assume that the other required plugins are 'standard' Eclipse plugins, such as EMF; those do not have to be in your workspace, as they are directly installed into your Eclipse platform.
Another way would be to put the original Jars into your plugin project. Just create a folder, e.g. lib/, paste the Jars there, and add them to the plugin project's class path. The latter is a bit tricky, as you have to add them in the Project Properties as well as in the Manifest.ml (in the 'runtime' tab of the plugin.xml-editor, IIRC) and the build.properties file.
Please read about the Eclipse target platform, as you seem not to be aware of that concept.
Generally speaking, there is an Eclipse environment in which you develop your code (which you use), and there is another Eclipse environment, in which your developed plugin runs (i.e. which a user of your plugin uses). That second one is called "target platform" in Eclipse terms. And they can be different, e.g. you develop in Eclipse 4.2, but your plugins shall run in Eclipse 3.7.
If you don't create a target platform yourself, then Eclipse just assumes its current installation to be the target platform (i.e. your development environment). That is why all "normal" plugins can be used as dependencies without them being in the workspace. But your icePdf plugin is not part of the Eclipse installation (and therefore not part of the target platform), which is why it needs to be available in the workspace.
If you define a target platform, you can then simply add those icepdf plugins to it and don't need to have them in the workspace any longer.

Programatically installing an Eclipse plugin from within Eclipse?

I want to create an automated installer for an Eclipse plugin (i.e. not through the "Update Manager"). My scenario is simple: the user closes Eclipse, drops a downloaded JAR into the dropins folder, starts Eclipse and the rest of the process is automated.
In older Eclipse versions, before the era of P2, Eclipse had (still has) a class called InstallCommand which could be used to install pluings into the currently running platform.
While this still works in Eclipse 3.4 & 3.5, it is not behaving properly: most noticeably, plugins installed that way cannot be automatically uninstalled (it is dimmed).
The JavaDoc claims the InstallCommand is deprecated and should be replaced by a P2 alternative. However, I couldn't find the right tool for the job. There is the P2 director, but it is built for running as a separate application from the command line. It is possible to invoke it from within Eclipse but it is really not cut out for that. For example, progress monitoring and error reporting are not working well.
Does anybody know of a good alternative for that?
Thanks,
Zviki
Dropins seems very close to what you want, especially if they are just downloading jars without the associated metadata (ie the metadata will need to be auto-generated).
You could consider defining a second dropins area to manage yourself. Take a look at ProfileSynchronizer in org.eclipse.equinox.p2.reconciler.dropins, in particular the method createProfileChangeRequest. I expect the uninstall behaviour you don't like is a result of the IInstallableUnit.PROP_PROFILE_LOCKED_IU property being added.
The dropins are reconciled at startup, see the p2.reconciler.dropins Activator.watchDropins(), you can likely do the same from your own bundle to watch another folder.
I suggest to deploy your plugin as an executable JAR. The installer in the JAR should ask for the Eclipse install directory and unpack the plugin in the right place (plus some more checks as needed).
Optionally include a little "watchdog" plugin which doesn't depend on much and just checks that your main plugin loads correctly and displays a useful error message which the user can email to you for support.
According to information in bug 311590 1 which is referenced in the deprecation comment of InstallCommand an alternative is possibly to use P2 operations 2, 3.

Modifying Existing Eclipse Plugin and Correctly Installing it

I downloaded the source code for the EMF based UML2 Plugin and changed a class in the org.eclipse.uml2.uml.edit project to remove special characters when returning string representations. Now when I export the projects and place the jar files either in the dropins directory or replace my current uml2 plugin jar files in plugins directory, The UML files are no longer recognized, in short my modified plugin does not install correctly (no error is thrown and I can see the files being picked up under Plugins->Target Platform) .
However, When I run the plugin as an eclipse application (from the workspace) I can see the changes I made being reflected in the new instance of eclipse.
What can I do to ensure that the plugin installs correctly?
Is there a documented procedure of how to build the uml2 plugin (or any comparable plugin) after modification?
Select the project and open the context menu. There is an entry PDE near the bottom of the menu. In there, you can find an entry to build the plugin for deployment. This gives you the features and plugins directory with the fixed files. Copy both into your Eclipse install.
Unless the UML2 plugins require some kind of magic build script, exporting the one plugin you changed and overwriting the original in your Eclipse installation should be the easiest solution. One potential problem which comes to mind is conflicting plugin version numbers: make sure you don't have two identical versions of your modified plugin in your Eclipse installation.
When debugging plugins which apparently don't work properly at runtime, I always look at Help > About Eclipse Platform > Configuration Details. This lists all the plugins found by Equinox during startup, along with their status (see the Javadoc of the org.osgi.framework.Bundle interface for explanation).
I faced the exact same problem as you describe here . I dont have any answer to your problem but i am sharing what worked for me .
I created a local update site of the plugin on my system. Create update site for your plug-in article explains very very nicely the steps needed to accomplish this .