summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2013-01-07 17:16:53 (EST)
committer Curtis Windatt2013-01-07 17:16:53 (EST)
commit7342c9bb2552646017d0cb93f02690d0869e21af (patch)
treedca69a327b4df8bca95d56dddcfb75ebc01d8eb1
parentfaa18e17f47c01dfdb6a76d93abe79aae0adf318 (diff)
downloadeclipse.pde.ui-7342c9bb2552646017d0cb93f02690d0869e21af.zip
eclipse.pde.ui-7342c9bb2552646017d0cb93f02690d0869e21af.tar.gz
eclipse.pde.ui-7342c9bb2552646017d0cb93f02690d0869e21af.tar.bz2
Bug 363733 - Provide possibility to enhancev20130107-221653
RequiredPluginsClasspathContainer to deal with Equinox-AdapterHooks
-rw-r--r--ui/org.eclipse.pde.core/META-INF/MANIFEST.MF2
-rw-r--r--ui/org.eclipse.pde.core/plugin.xml3
-rw-r--r--ui/org.eclipse.pde.core/schema/pluginClasspathContributors.exsd119
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/core/IClasspathContributor.java59
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java54
5 files changed, 234 insertions, 3 deletions
diff --git a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
index 257ba49..1e72f2f 100644
--- a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %name
Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true
-Bundle-Version: 3.8.100.qualifier
+Bundle-Version: 3.9.0.qualifier
Bundle-Activator: org.eclipse.pde.internal.core.PDECore
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
diff --git a/ui/org.eclipse.pde.core/plugin.xml b/ui/org.eclipse.pde.core/plugin.xml
index 6d540a5..012ca38 100644
--- a/ui/org.eclipse.pde.core/plugin.xml
+++ b/ui/org.eclipse.pde.core/plugin.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?><!--
- Copyright (c) 2005, 2011 IBM Corporation and others.
+ Copyright (c) 2005, 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@
<extension-point id="targets" name="%expoint.target.name" schema="schema/targets.exsd"/>
<extension-point id="targetLocations" name="%expoint.targetlocation.name" schema="schema/targetLocations.exsd"/>
<extension-point id="bundleClasspathResolvers" name="%expoint.bundleClasspathResolvers.name" schema="schema/bundleClasspathResolvers.exsd"/>
+ <extension-point id="pluginClasspathContributors" name="pluginClasspathContributors" schema="schema/pluginClasspathContributors.exsd"/>
<extension
point="org.eclipse.jdt.core.classpathVariableInitializer">
diff --git a/ui/org.eclipse.pde.core/schema/pluginClasspathContributors.exsd b/ui/org.eclipse.pde.core/schema/pluginClasspathContributors.exsd
new file mode 100644
index 0000000..11b06d7
--- /dev/null
+++ b/ui/org.eclipse.pde.core/schema/pluginClasspathContributors.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.pde.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.pde.core" id="pluginClasspathContributors" name="Plug-in Classpath Contributors"/>
+ </appinfo>
+ <documentation>
+ This extension point provides a mechanism to contribute additional classpath entries to a plug-in project when the PDE classpath is computered. Each plug-in classpath contributor is consulted for additional entries when the initial classpath is calculated as well as whenever a new bundle dependency is added to the project.
+
+The additional classpath entries are only stored as long as the project classpath is. The additional entries will not be considered during plug-in or feature export.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="contributor"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contributor">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The class that implements the plug-in classpath contributor. The class must implement &lt;code&gt;IClasspathContributor&lt;/code&gt;
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.pde.core.IClasspathContributor"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 3.9
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ The following is an example of the classpath contributor
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension
+ point=&quot;org.eclipse.pde.core.pluginClasspathContributors&quot;&gt;
+ &lt;contribtor
+ class=&quot;at.bestsolution.efxclipse.tooling.pde.core.JavaFXClassPathExtender&quot;&gt;
+ &lt;/contribtor&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ Each contributor must provide a class that implements &lt;code&gt;org.eclipse.pde.core.IClasspathContributor&lt;/code&gt;
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2013 BestSolution.at and others.&amp;lt;br&amp;gt;
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+&amp;lt;a href=&amp;quot;http://www.eclipse.org/legal/epl-v10.html&amp;quot;&amp;gt;http://www.eclipse.org/legal/epl-v10.html&amp;lt;/a&amp;gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/IClasspathContributor.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/IClasspathContributor.java
new file mode 100644
index 0000000..b069c06
--- /dev/null
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/IClasspathContributor.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BestSolution.at - initial API and implementation
+ * IBM Corporation - ongoing enhancements
+ *******************************************************************************/
+package org.eclipse.pde.core;
+
+import java.util.List;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.pde.core.plugin.PluginRegistry;
+
+/**
+ * Implementors of this interface can contribute additional {@link IClasspathEntry}
+ * to a plug-in project as the classpath is computed. The contributor is consulted
+ * when the initial classpath for a plug-in project is calculated as well as whenever
+ * a new bundle dependency is created.
+ * <p>
+ * A classpath contributor is declared as an extension (<code>org.eclipse.pde.core.pluginClasspathContributors</code>).
+ * </p>
+ * <p>
+ * The added classpath entries are only stored as long as the project classpath is and will
+ * not be considered during plug-in or feature export.
+ * </p>
+ *
+ * @since 3.9
+ */
+public interface IClasspathContributor {
+
+ /**
+ * Get any additional classpath entries to add to a project when its classpath is
+ * first computed. The provided {@link BundleDescription} describes the plug-in
+ * project that the classpath is being computed for. Additional PDE model information
+ * can be obtained using {@link PluginRegistry#findModel(BundleDescription)}.
+ *
+ * @param project the bundle descriptor for the plug-in project having its classpath computed
+ * @return additional classpath entries to add to the project, possibly empty, must not be <code>null</code>
+ */
+ public List<IClasspathEntry> getInitialEntries(BundleDescription project);
+
+ /**
+ * Get any additional classpath entries to add to a project when a new bundle
+ * is being added to the project classpath as a dependency. The {@link BundleDescription}
+ * is provided for both the plug-in that the classpath is being calculated for and
+ * the dependency being added. The dependency may be a project in the workspace or an
+ * external bundle from the target platform.
+ *
+ * @param project the bundle descriptor for the plug-in project having its classpath computed
+ * @param addedDependency the bundle descriptor for the bundle being added to the classpath as a dependency
+ * @return additional classpath entries to add to the project, possibly empty, must not be <code>null</code>
+ */
+ public List<IClasspathEntry> getEntriesForDependency(BundleDescription project, BundleDescription addedDependency);
+}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java
index 8313412..5fb3479 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@ import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.pde.core.IClasspathContributor;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.plugin.IPluginModelBase;
@@ -32,6 +33,12 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp
private IClasspathEntry[] fEntries = null;
+ /**
+ * Cached list of {@link IClasspathContributor} from plug-in extensions
+ * @see #getClasspathContributors()
+ */
+ private List<IClasspathContributor> fClasspathContributors = null;
+
static {
DEBUG = PDECore.getDefault().isDebugging() && "true".equals(Platform.getDebugOption("org.eclipse.pde.core/classpath")); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -106,6 +113,15 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp
Map<BundleDescription, ArrayList<Rule>> map = retrieveVisiblePackagesFromState(desc);
+ // Add any library entries contributed via classpath contributor extension (Bug 363733)
+ for (IClasspathContributor cc : getClasspathContributors()) {
+ List<IClasspathEntry> classpathEntries = cc.getInitialEntries(desc);
+ if (classpathEntries == null || classpathEntries.isEmpty()) {
+ continue;
+ }
+ entries.addAll(classpathEntries);
+ }
+
HashSet<BundleDescription> added = new HashSet<BundleDescription>();
// to avoid cycles, e.g. when a bundle imports a package it exports
@@ -159,6 +175,27 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp
return entries.toArray(new IClasspathEntry[entries.size()]);
}
+ /**
+ * Return the list of {@link IClasspathContributor}s provided by the
+ * <code>org.eclipse.pde.core.pluginClasspathContributors</code> extension point.
+ * @return list of classpath contributors from the extension point
+ */
+ private List<IClasspathContributor> getClasspathContributors() {
+ if (fClasspathContributors == null) {
+ fClasspathContributors = new ArrayList<IClasspathContributor>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.core.pluginClasspathContributors"); //$NON-NLS-1$
+ for (int i = 0; i < elements.length; i++) {
+ try {
+ fClasspathContributors.add((IClasspathContributor) elements[i].createExecutableExtension("class")); //$NON-NLS-1$
+ } catch (CoreException e) {
+ PDECore.log(e.getStatus());
+ }
+ }
+ }
+ return fClasspathContributors;
+ }
+
private Map<BundleDescription, ArrayList<Rule>> retrieveVisiblePackagesFromState(BundleDescription desc) {
Map<BundleDescription, ArrayList<Rule>> visiblePackages = new HashMap<BundleDescription, ArrayList<Rule>>();
StateHelper helper = Platform.getPlatformAdmin().getStateHelper();
@@ -248,8 +285,23 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp
IPluginModelBase model = PluginRegistry.findModel(desc);
if (model == null || !model.isEnabled())
return false;
+
IResource resource = model.getUnderlyingResource();
Rule[] rules = useInclusions ? getInclusions(map, model) : null;
+
+ BundleDescription hostBundle = fModel.getBundleDescription();
+ if (desc == null)
+ return false;
+
+ // Add any library entries contributed via classpath contributor extension (Bug 363733)
+ for (IClasspathContributor cc : getClasspathContributors()) {
+ List<IClasspathEntry> classpathEntries = cc.getEntriesForDependency(hostBundle, desc);
+ if (classpathEntries == null || classpathEntries.isEmpty()) {
+ continue;
+ }
+ entries.addAll(classpathEntries);
+ }
+
if (resource != null) {
addProjectEntry(resource.getProject(), rules, entries);
} else {