Bug 323902 - Use Import-Package for dependencies
Summary: Use Import-Package for dependencies
Status: RESOLVED FIXED
Alias: None
Product: MAT
Classification: Tools
Component: GUI (show other bugs)
Version: 1.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Krum Tsvetkov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 351842
Blocks: 262603
  Show dependency tree
 
Reported: 2010-08-29 05:45 EDT by Benjamin Muskalla CLA
Modified: 2013-01-28 10:12 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Muskalla CLA 2010-08-29 05:45:30 EDT
In order to better support RAP (bug 262603), we should use Import-Packages in the manifests instead of harcoding the bundles with Require-Bundle. This is based on the fact that RAP deploys the same API but within other bundles (org.eclipse.ui -> org.eclipse.rap.ui) not to clash with RCP bundles. Using Import-Packages would help to depend on the right bundles at runtime.
We can leverage PDEs automatic dependency management to help with this task.

If there are no objections. I'd provide a patch for this.
Comment 1 Andrew Johnson CLA 2010-08-31 07:58:49 EDT
Another example of where we use Import-Package is com.ibm.icu.text See http://wiki.eclipse.org/ICU4J#Replacement_Plug-in

Here is some discussion of possible difficulties:

http://eclipsesource.com/blogs/2009/07/14/why-i-cant-recommend-using-import-package/

The alternatives appear to be:
1.Import-Package
2.Optional dependencies on both the swt and rap plugins
3.Compatibility plugin - which optionally depends on both, and reexports them
4.Would putting the dependencies in a fragment plugin work?

I would like to see the patch as it seems the simplest option.
Comment 2 Benjamin Muskalla CLA 2010-08-31 21:48:12 EDT
I really recommend to use Import-Packages in our situation as we will not suffer from the split package problems due to some IDE dependencies. This way it is cleaner to maintain than having optional dependencies on both runtimes. The only drawback of this approach is that we need to define unversioned package imports for the time being (see bug 286880).
Comment 3 Andrew Johnson CLA 2010-09-14 05:30:28 EDT
By experiment, the changes for RCP seem to be to be to add
 org.eclipse.ui,
 org.eclipse.ui.help,
 org.eclipse.ui.intro,
 org.eclipse.ui.plugin,
 org.eclipse.ui.progress,
 org.eclipse.ui.themes
as import-packages, remove org.eclipse.ui as a bundle and add org.eclipse.jface (which used to be reexported from the org.eclipse.ui bundle).

I'll see whether they work for RAP.
Comment 4 Krum Tsvetkov CLA 2011-10-24 09:14:56 EDT
I had a go and changed the following plugins to use Import-Package instead of Require-Bundle for the org.eclipse.ui.
org.eclipse.mat.chart.ui
org.eclipse.mat.ui
org.eclipse.mat.ui.help
org.eclipse.mat.ui.rcp

The Tycho was fine, and the (locally) produced RCP was usable. 
This is just the first iteration. The dependencies are still not versioned  and I didn't change the org.eclipse.mat.dtfj plugin.
It has an optional reference to the org.eclipse.ui bundle. Actually I got the changes working in the IDE, but Tycho couldn't build, so for the moment I postponed the change.
This is the import list for DTFJ, just to have it somewhere saved:
Import-Package: com.ibm.icu.text;version="3.6.1",
 org.eclipse.jface.preference;resolution:=optional,
 org.eclipse.jface.dialogs;resolution:=optional,
 org.eclipse.ui;resolution:=optional,
 org.eclipse.ui.preferences;resolution:=optional,
 org.eclipse.swt.graphics;resolution:=optional,
 org.eclipse.swt.widgets;resolution:=optional,
 org.eclipse.core.commands.common;resolution:=optional
 
 About versioning - we import all UI related bundles with version 3.3.0 (which seems to be 3.3.0 and higher).
 I am not sure if this is still valid. What would be a good version range for the packages?
Comment 5 Andrew Johnson CLA 2012-02-21 11:36:44 EST
Bug 351842 might explain how to cope with optional dependencies with Tycho
Comment 6 Andrew Johnson CLA 2013-01-04 04:24:11 EST
I've updated the org.eclipse.mat.dtfj plugin too. Initially I got this error 

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.16.0:compile (default-compile) on project org.eclipse.mat.dtfj: Compilation failure: Compilation failure:
[ERROR] /opt/users/hudsonbuild/workspace/tycho-mat-nightly/trunk/plugins/org.eclipse.mat.dtfj/src/org/eclipse/mat/dtfj/DTFJPreferencePage.java:[16,0]
[ERROR] import org.eclipse.ui.IWorkbench;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type IWorkbench is not accessible due to restriction on classpath entry /opt/users/hudsonbuild/workspace/tycho-mat-nightly/.repository/p2/osgi/bundle/org.eclipse.ui.workbench/3.7.1.v20120104-1859/org.eclipse.ui.workbench-3.7.1.v20120104-1859.jar
[ERROR] /opt/users/hudsonbuild/workspace/tycho-mat-nightly/trunk/plugins/org.eclipse.mat.dtfj/src/org/eclipse/mat/dtfj/DTFJPreferencePage.java:[17,0]
[ERROR] import org.eclipse.ui.IWorkbenchPreferencePage;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type IWorkbenchPreferencePage is not accessible due to restriction on classpath entry /opt/users/hudsonbuild/workspace/tycho-mat-nightly/.repository/p2/osgi/bundle/org.eclipse.ui.workbench/3.7.1.v20120104-1859/org.eclipse.ui.workbench-3.7.1.v20120104-1859.jar
[ERROR] /opt/users/hudsonbuild/workspace/tycho-mat-nightly/trunk/plugins/org.eclipse.mat.dtfj/src/org/eclipse/mat/dtfj/DTFJPreferencePage.java:[30,0]
[ERROR] public class DTFJPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] Access restriction: The type IWorkbenchPreferencePage is not accessible due to restriction on classpath entry /opt/users/hudsonbuild/workspace/tycho-mat-nightly/.repository/p2/osgi/bundle/org.eclipse.ui.workbench/3.7.1.v20120104-1859/org.eclipse.ui.workbench-3.7.1.v20120104-1859.jar
[ERROR] /opt/users/hudsonbuild/workspace/tycho-mat-nightly/trunk/plugins/org.eclipse.mat.dtfj/src/org/eclipse/mat/dtfj/DTFJPreferencePage.java:[66,0]
[ERROR] public void init(IWorkbench workbench)
[ERROR] ^^^^^^^^^^
[ERROR] Access restriction: The type IWorkbench is not accessible due to restriction on classpath entry /opt/users/hudsonbuild/workspace/tycho-mat-nightly/.repository/p2/osgi/bundle/org.eclipse.ui.workbench/3.7.1.v20120104-1859/org.eclipse.ui.workbench-3.7.1.v20120104-1859.jar
[ERROR] 4 problems (4 errors)
[ERROR] -> [Help 1]
[ERROR] 

which needed a split package declaration to fix.
 org.eclipse.ui;ui.workbench="split";resolution:=optional,

What more do we need to do?
Comment 7 Krum Tsvetkov CLA 2013-01-28 10:12:22 EST
I don't think there is something more at the moment.
I'll close the ticket. We could track further activities if needed in this ticket (reopen) or in new ones.