View | Details | Raw Unified | Return to bug 363733 | Differences between
and this patch

Collapse All | Expand All

(-)a/ui/org.eclipse.pde.core/plugin.xml (+1 lines)
Lines 17-22 Link Here
17
     <extension-point id="targets" name="%expoint.target.name" schema="schema/targets.exsd"/>
17
     <extension-point id="targets" name="%expoint.target.name" schema="schema/targets.exsd"/>
18
     <extension-point id="targetLocations" name="%expoint.targetlocation.name" schema="schema/targetLocations.exsd"/>
18
     <extension-point id="targetLocations" name="%expoint.targetlocation.name" schema="schema/targetLocations.exsd"/>
19
     <extension-point id="bundleClasspathResolvers" name="%expoint.bundleClasspathResolvers.name" schema="schema/bundleClasspathResolvers.exsd"/>
19
     <extension-point id="bundleClasspathResolvers" name="%expoint.bundleClasspathResolvers.name" schema="schema/bundleClasspathResolvers.exsd"/>
20
     <extension-point id="pluginClasspathContributors" name="pluginClasspathContributors" schema="schema/pluginClasspathContributors.exsd"/>
20
21
21
   <extension
22
   <extension
22
         point="org.eclipse.jdt.core.classpathVariableInitializer">
23
         point="org.eclipse.jdt.core.classpathVariableInitializer">
(-)a/ui/org.eclipse.pde.core/schema/pluginClasspathContributors.exsd (+122 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.pde.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.pde.core" id="pluginClasspathContributors" name="pluginClasspathContributors"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point allows clients to contribute to the classpath resolving of PDE projects:
10
11
&lt;p&gt;
12
&lt;pre&gt;
13
  &lt;extension
14
    point=&quot;org.eclipse.pde.core.pluginClasspathContributors&quot;&gt;
15
    &lt;contribtor
16
      class=&quot;at.bestsolution.efxclipse.tooling.pde.core.JavaFXClassPathExtender&quot;&gt;
17
    &lt;/contribtor&gt;
18
  &lt;/extension&gt;
19
&lt;/pre&gt;
20
&lt;/p&gt;
21
      </documentation>
22
   </annotation>
23
24
   <element name="extension">
25
      <annotation>
26
         <appInfo>
27
            <meta.element />
28
         </appInfo>
29
      </annotation>
30
      <complexType>
31
         <sequence minOccurs="1" maxOccurs="unbounded">
32
            <element ref="contribtor"/>
33
         </sequence>
34
         <attribute name="point" type="string" use="required">
35
            <annotation>
36
               <documentation>
37
                  
38
               </documentation>
39
            </annotation>
40
         </attribute>
41
         <attribute name="id" type="string">
42
            <annotation>
43
               <documentation>
44
                  
45
               </documentation>
46
            </annotation>
47
         </attribute>
48
         <attribute name="name" type="string">
49
            <annotation>
50
               <documentation>
51
                  
52
               </documentation>
53
               <appInfo>
54
                  <meta.attribute translatable="true"/>
55
               </appInfo>
56
            </annotation>
57
         </attribute>
58
      </complexType>
59
   </element>
60
61
   <element name="contribtor">
62
      <annotation>
63
         <documentation>
64
            the contributor informations
65
         </documentation>
66
      </annotation>
67
      <complexType>
68
         <attribute name="class" type="string" use="required">
69
            <annotation>
70
               <documentation>
71
                  the contributing class
72
               </documentation>
73
               <appInfo>
74
                  <meta.attribute kind="java" basedOn=":org.eclipse.pde.core.IClasspathContributor"/>
75
               </appInfo>
76
            </annotation>
77
         </attribute>
78
      </complexType>
79
   </element>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="since"/>
84
      </appInfo>
85
      <documentation>
86
         3.9
87
      </documentation>
88
   </annotation>
89
90
   <annotation>
91
      <appInfo>
92
         <meta.section type="examples"/>
93
      </appInfo>
94
      <documentation>
95
         The following is an example of the classpath contributor
96
      </documentation>
97
   </annotation>
98
99
   <annotation>
100
      <appInfo>
101
         <meta.section type="apiinfo"/>
102
      </appInfo>
103
      <documentation>
104
         Each contributor must provide a class that implements &lt;code&gt;org.eclipse.pde.core.IClasspathContributor&lt;/code&gt;
105
      </documentation>
106
   </annotation>
107
108
109
   <annotation>
110
      <appInfo>
111
         <meta.section type="copyright"/>
112
      </appInfo>
113
      <documentation>
114
         Copyright (c) 2012 BestSolution.at and others.&amp;lt;br&amp;gt;
115
All rights reserved. This program and the accompanying materials
116
are made available under the terms of the Eclipse Public License v1.0
117
which accompanies this distribution, and is available at
118
&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;
119
      </documentation>
120
   </annotation>
121
122
</schema>
(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/IClasspathContributor.java (+84 lines)
Added Link Here
1
package org.eclipse.pde.core;
2
3
import java.util.List;
4
import org.eclipse.core.runtime.IPath;
5
import org.eclipse.jdt.core.IClasspathAttribute;
6
import org.eclipse.osgi.service.resolver.BundleDescription;
7
import org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer;
8
9
/**
10
 * Implementors of this interface can contribute to the classpath calculation
11
 * of the {@link RequiredPluginsClasspathContainer}
12
 */
13
public interface IClasspathContributor {
14
	/**
15
	 * Access rule for a package
16
	 */
17
	public static class Rule {
18
		public final IPath path;
19
		public final boolean discouraged;
20
21
		public Rule(IPath path, boolean discouraged) {
22
			this.path = path;
23
			this.discouraged = discouraged;
24
		}
25
	}
26
27
	/**
28
	 * Contribution to the classpath
29
	 */
30
	public static class Contribution {
31
		/**
32
		 * Location of the jar, must not be <code>null</code>
33
		 */
34
		public final IPath jarLocation;
35
		/**
36
		 * Location of the JavaDoc, might be <code>null</code>
37
		 */
38
		public final String javaDocLocation;
39
		/**
40
		 * Location of the Source-Code, might be <code>null</code>
41
		 */
42
		public final IPath sourceLocation;
43
		/**
44
		 * Additional classpath attributes, might be <code>null</code>
45
		 */
46
		public final IClasspathAttribute[] attributes;
47
		/**
48
		 * Access rules, might be <code>null</code>
49
		 */
50
		public final Rule[] rules;
51
52
		/**
53
		 * Create a new contribution
54
		 * 
55
		 * @param jarLocation the location of jar-file, must not be <code>null</code>
56
		 * @param javaDocLocation the location of the javadoc, might be <code>null</code>
57
		 * @param sourceLocation the location of the source, might be <code>null</code>
58
		 * @param attributes additional classpath attributes, might be <code>null</code>
59
		 * @param rules access rules, might be <code>null</code>
60
		 */
61
		public Contribution(IPath jarLocation, String javaDocLocation, IPath sourceLocation, IClasspathAttribute[] attributes, Rule[] rules) {
62
			super();
63
			this.jarLocation = jarLocation;
64
			this.javaDocLocation = javaDocLocation;
65
			this.sourceLocation = sourceLocation;
66
			this.attributes = attributes;
67
			this.rules = rules;
68
		}
69
	}
70
71
	/**
72
	 * Get contributions for the given host bundle (=bundle the classpath container is created for)
73
	 * @param desc the bundle descriptor
74
	 * @return the contributions, must not be <code>null</code>
75
	 */
76
	public List<Contribution> getHostBundleContributions(BundleDescription desc);
77
78
	/**
79
	 * Get contributions for the given bundle resolved for the host bundle
80
	 * @param desc the bundle descriptor
81
	 * @return the contributions, must not be <code>null</code>
82
	 */
83
	public List<Contribution> getReferencedBundleContributions(BundleDescription desc);
84
}
(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java (+85 lines)
Lines 16-21 import org.eclipse.core.resources.*; Link Here
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.jdt.core.*;
17
import org.eclipse.jdt.core.*;
18
import org.eclipse.osgi.service.resolver.*;
18
import org.eclipse.osgi.service.resolver.*;
19
import org.eclipse.pde.core.IClasspathContributor;
20
import org.eclipse.pde.core.IClasspathContributor.Contribution;
19
import org.eclipse.pde.core.build.IBuild;
21
import org.eclipse.pde.core.build.IBuild;
20
import org.eclipse.pde.core.build.IBuildEntry;
22
import org.eclipse.pde.core.build.IBuildEntry;
21
import org.eclipse.pde.core.plugin.IPluginModelBase;
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
Lines 32-37 public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp Link Here
32
34
33
	private IClasspathEntry[] fEntries = null;
35
	private IClasspathEntry[] fEntries = null;
34
36
37
	private IClasspathContributor[] fClasspathContributors = null;
38
35
	static {
39
	static {
36
		DEBUG = PDECore.getDefault().isDebugging() && "true".equals(Platform.getDebugOption("org.eclipse.pde.core/classpath")); //$NON-NLS-1$ //$NON-NLS-2$
40
		DEBUG = PDECore.getDefault().isDebugging() && "true".equals(Platform.getDebugOption("org.eclipse.pde.core/classpath")); //$NON-NLS-1$ //$NON-NLS-2$
37
	}
41
	}
Lines 46-51 public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp Link Here
46
	public RequiredPluginsClasspathContainer(IPluginModelBase model, IBuild build) {
50
	public RequiredPluginsClasspathContainer(IPluginModelBase model, IBuild build) {
47
		fModel = model;
51
		fModel = model;
48
		fBuild = build;
52
		fBuild = build;
53
54
		List<IClasspathContributor> list = new ArrayList<IClasspathContributor>();
55
		IExtensionRegistry registry = Platform.getExtensionRegistry();
56
		IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.core.pluginClasspathContributors"); //$NON-NLS-1$
57
		for (int i = 0; i < elements.length; i++) {
58
			try {
59
				list.add((IClasspathContributor) elements[i].createExecutableExtension("class")); //$NON-NLS-1$
60
			} catch (CoreException e) {
61
				PDECore.log(e.getStatus());
62
			}
63
		}
64
		fClasspathContributors = new IClasspathContributor[list.size()];
65
		list.toArray(fClasspathContributors);
49
	}
66
	}
50
67
51
	/*
68
	/*
Lines 111-116 public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp Link Here
111
			// to avoid cycles, e.g. when a bundle imports a package it exports
128
			// to avoid cycles, e.g. when a bundle imports a package it exports
112
			added.add(desc);
129
			added.add(desc);
113
130
131
			for (IClasspathContributor cc : fClasspathContributors) {
132
				List<Contribution> contribs = cc.getHostBundleContributions(desc);
133
				if (contribs == null || contribs.isEmpty()) {
134
					continue;
135
				}
136
137
				for (Contribution c : contribs) {
138
					if (c.jarLocation == null) {
139
						continue;
140
					}
141
					Rule[] rs = new Rule[c.rules != null ? c.rules.length : 0];
142
					for (int i = 0; i < rs.length; i++) {
143
						Rule r = new Rule();
144
						r.path = c.rules[i].path;
145
						r.discouraged = c.rules[i].discouraged;
146
						System.err.println(r.path);
147
						rs[i] = r;
148
					}
149
150
					IClasspathAttribute[] attr = null;
151
					if (c.javaDocLocation != null) {
152
						if (c.attributes != null) {
153
							attr = new IClasspathAttribute[c.attributes.length + 1];
154
							System.arraycopy(c.attributes, 0, attr, 0, c.attributes.length);
155
						} else {
156
							attr = new IClasspathAttribute[1];
157
						}
158
						attr[attr.length - 1] = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, c.javaDocLocation);
159
					} else {
160
						attr = c.attributes;
161
					}
162
163
					addLibraryEntry(c.jarLocation, c.sourceLocation, rs, attr, entries);
164
				}
165
			}
166
114
			HostSpecification host = desc.getHost();
167
			HostSpecification host = desc.getHost();
115
			if (host != null) {
168
			if (host != null) {
116
				addHostPlugin(host, added, map, entries);
169
				addHostPlugin(host, added, map, entries);
Lines 248-255 public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp Link Here
248
		IPluginModelBase model = PluginRegistry.findModel(desc);
301
		IPluginModelBase model = PluginRegistry.findModel(desc);
249
		if (model == null || !model.isEnabled())
302
		if (model == null || !model.isEnabled())
250
			return false;
303
			return false;
304
251
		IResource resource = model.getUnderlyingResource();
305
		IResource resource = model.getUnderlyingResource();
252
		Rule[] rules = useInclusions ? getInclusions(map, model) : null;
306
		Rule[] rules = useInclusions ? getInclusions(map, model) : null;
307
308
		for (IClasspathContributor cp : fClasspathContributors) {
309
			List<Contribution> contribs = cp.getReferencedBundleContributions(desc);
310
			if (contribs == null || contribs.isEmpty()) {
311
				continue;
312
			}
313
314
			for (Contribution c : contribs) {
315
				IClasspathAttribute[] attributes = new IClasspathAttribute[0];
316
				if (c.jarLocation == null) {
317
					continue;
318
				}
319
320
				if (c.attributes == null) {
321
					if (c.javaDocLocation != null) {
322
						attributes = new IClasspathAttribute[] {JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, c.javaDocLocation)};
323
					}
324
				} else {
325
					if (c.javaDocLocation != null) {
326
						attributes = new IClasspathAttribute[c.attributes.length + 1];
327
						attributes[attributes.length - 1] = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, c.javaDocLocation);
328
					} else {
329
						attributes = new IClasspathAttribute[c.attributes.length];
330
					}
331
					System.arraycopy(c.attributes, 0, attributes, 0, c.attributes.length);
332
				}
333
334
				addLibraryEntry(c.jarLocation, c.sourceLocation, rules, attributes, entries);
335
			}
336
		}
337
253
		if (resource != null) {
338
		if (resource != null) {
254
			addProjectEntry(resource.getProject(), rules, entries);
339
			addProjectEntry(resource.getProject(), rules, entries);
255
		} else {
340
		} else {

Return to bug 363733