Can I create an Eclipse Product without an RCP Application? - eclipse

We develop plug-ins and a feature, and want to deliver a running application to our customer (so they don't have to get Eclipse on their own). Basically, I want to put my plug-ins in a minimal Eclipse instance (minus jdt, junit, and other plug-ins that we don't need).
I created a product configuration, but it wants me to specify a Product and Application in the Product Definition definition section (of the Product Configuration editor). How to I know what to specify for these? Choosing willy-nilly gives me the following error when I click the Launch an Eclipse application from the Product Configuration editor:
java.lang.RuntimeException: No application id has been found.
I've created products successfully from an RCP application before, but in this case I just want to deliver the bulk of Eclipse with our plug-ins installed. Am I doing this right?

Application could be headless or have GUI like RCP.
Product is an abstract definition for your product, it must depend on a specific application to be executed. You could refer to the built-in applications of eclipse itself.

Related

Recommended way to get eclipse workspace path for Eclipse RCP with target 2022-09

We are developing an Eclipse RCP application, and up to target version 2022-03, we always used this to get the current workspace path:
ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()
But: with Eclipse target version 2022-09, we get an IllegalStateException, if we run the product outside of eclipse, i.e. the exported product:
java.lang.IllegalStateException: Workspace is already closed or not ready yet. Consider tracking the org.eclipse.core.resources.IWorkspace service (using your favorite technique, e.g. Declarative Services, ServiceTracker, Blueprint, ...) instead of calling the static method here to prevent such issues!
at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:502)
I mean, the exception does propose some alternatives. But: is it really not possible anymore to use ResourcesPlugin.getWorkspace()? This was quite convenient. Is there any equally simple solution?
The simplest way of getting the workspace location is:
URL location = Platform.getInstanceLocation().getURL();
Platform is org.eclipse.core.runtime.Platform.
This does not rely on the resources plug-in at all (so it even works in a e4 RCP without the resources plug-in).

Is there a difference between "starts" and "activates" for Eclipse RCP plugin?

When creating a plugin, in the manifest file there's an option to "Activate this plug-in when one of its classes is loaded":
Also, when configuring a product, there's also option to specify plugin Start Levels:
Is the concept of "starting" the same or different than "activating". If they're different, how so?
Start Levels are used to control the order in which plug-ins are started when Eclipse itself is starting up. This is necessary to ensure that some services are available when they are needed. The picture below shows the default start levels. At level 1 org.eclipse.equinox.simpleconfigurator is the plug-in that loads most of the other plug-ins - so it needs to start first!
'Activate this plug-in when one of its classes is loaded' is an option to control when the plug-in Activator class is called (if it has one). If this is specified the activator is not called until something needs to use one of the other classes in the plug-in. If not specified the Activator will only be called if the plug-in is started by 'Auto-Start' in the start levels or an explicit OSGi start call.
Note that many plug-ins don't need an Activator at all.

How to synchronize run configuration with product configuration in Eclipse?

I am trying to run an Eclipse product that is configured to use features.
The features added by me are:
org.eclipse.e4.rcp
org.eclipse.emf.ecore
org.eclipse.emf.common
The product will run after using the run configuration->add required plugins button (the product plugin itself is missing example: if the product plugin is called com.company.product I will get a validation error that com.company.product is missing).
If I am using "Launch an Eclipse application" I will get the error "No application id found". This is also obviously reflected in the exported product.
I tried to add the product plugin as dependency but I can't find it. Still the "add required plugins" can add it.
Why is the product plugin itself required and how to add it in the configuration such that the exported product can run ?
I' not sure I really understand the question, but if you are using a feature based product you need to write a feature containing all of your plugins including the one that defines the product using the org.eclipse.core.runtime.product extension point.
Every plugin that you want to be included in the RCP must be listed in a feature and all the features must be listed in the product file.
I don't know of anything that will synchronize the Run Configuration with the product file.

Exporting an GEF-Editor as a runnable JAR

As stated in the title: I want to run an Eclipse-Plugin, more specifically a GEF-Editor, without starting an Eclipse instance before.
I've tried to use the export functionality provided in the MANIFEST.MF file:
However, running the generated JAR (call it editor.jar) by executing java -jar editor.jar on the command line fails with the message no main manifest attribute, in plugins editor.jar.
I'm aware of the fact, that this is because my MANIFEST.MF file is missing the following line
Main-Class: <packagename>.<classname>
which defines an entry point for my application. However, I've no idea what exactly I need to do here (in the case of an Eclipse-Plugin), cause I don't have something like a main method. I assume Eclipse is running some magic code it doesn't show to me, when I start my project as an Eclipse Application.
So, what do I need to do?
You could try running a GEF editor as a Java application. See Draw2D examples to understand how it can be done. You could probably re-use your GraphicalViewer and PaletteViewer, which means that mouse based interactions with the diagram and palette will be preserved.
However, your editor class would probably have to be incorporated into an SWT shell. Also, all actions contributed to by your editor into Eclipse toolbars, popup menus etc. would be gone. Outline and Tree view would have to be incorporated into your java app somehow if needed.
Think you'd be better off with an RCP application.
Wrap your GEF editor in a simple RCP. You can create one via the Plug-in wizard, setting "Would you create a rich client application?" to "Yes" in the process. This gives you the option to create a minimal application via the Hello World template in the next step. Once you have this, you can either embed your GEF editor in this plugin, or declare a dependency from the new RCP application to your GEF editor plugin, and start the editor from the Application class' start method.
For an overview of resources about RCP development, cf. Getting started with the Eclipse RCP.
It really doesn't add that much overhead to your editor but gives you the opportunity to work with the platform's workbench and workspace metaphors and create easy-to-deploy-and-use application bundles.
Once you have that in place, you can test your RCP from plugin.xml > Overview > Testing > Launch an Eclipse application. This will not run a whole new instance of the IDE, but just the RCP application itself.
Rather than exporting from the MANIFEST.MF, look into creating a product (you can do it via the wizard: New > Product Configuration), and building it via the Maven Tycho plugin(s) (have a look at the respective - really worthwhile - tutorial from EclipseCon Europe 2012: http://eclipsecon.org/europe2012/sessions/building-eclipse-plugins-and-rcp-applications-tycho.html, this includes a section on creating a product as well). Tycho gives true cross-platform builds, as long as you're not on Windows.
No magic code there :).

Dependencies of my RCP application are missing on my update site

I am creating an RCP application. I am planning to provide p2 update functionality.
For example there are 4 plugins: A,B,C,D
Plugin A and B represents the core functionality of my RCP application. I have created a feature with name com.myorg.feature.core. In-side the feature.xml, in the plugin tab I have added plugins A & B.
I am adding feature com.myorg.feature.core as a dependecy in the product file of my RCP applicaton. After that I export the RCP application using product file (here product is a feature based product).
Now I have created two more features.
com.myorg.feature.featureC
com.myorg.feature.featureD
As these are optional functionalities to my RCP application, I want user to chose, whether to install them or not. So user will chose the install new software option where this features will be list.
The problem I am facing is, these plugins C & D are using certain 3rd party libraries e.g. BIRT, NATTABLE. So each time, I build featureC or featureD, put it on the update site and I try to install them in my application, they show the dependency failures, like bundle missing: org.eclipse.birt.core
I go back to the feature.xml for featureC -> plugins tab -> add org.eclipse.birt.core and build feature again. But several times my RCP application failed to install with errors bundles missing.
Is there any mechanism where I can determine all the required bundle from start? Is is the right way to launch updates or new install-able units for my RCP application?
#Priank it is better to add all dependencies in plugins tab in feature.xml, this is only one time effort. You can compute required plugins from dependencies tab of feature.xml
To me, the first question should be if you really want to use the Eclipse PDE export wizards for delivering updates.
Instead, you should set up a headless build for your project. If you are familiar with the PDE (and don't happen to hate Maven ;-), Tycho is probably the right choice for you. (Disclaimer: I'm committer on the Tycho project, and may not know all potential alternatives.)
You can easily make Tycho include all the transitive dependencies in a p2 repository: Just set the option includeAllDependencies to true on the tycho-p2-repository-plugin.