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

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %name
3
Bundle-Name: %name
4
Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true
4
Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true
5
Bundle-Version: 3.7.100.qualifier
5
Bundle-Version: 3.8.0.qualifier
6
Bundle-Activator: org.eclipse.pde.internal.core.PDECore
6
Bundle-Activator: org.eclipse.pde.internal.core.PDECore
7
Bundle-Vendor: %provider-name
7
Bundle-Vendor: %provider-name
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
(-)plugin.properties (+1 lines)
Lines 18-23 Link Here
18
expoint.source.name = Code Source Locations
18
expoint.source.name = Code Source Locations
19
expoint.javadoc.name = Javadoc Locations
19
expoint.javadoc.name = Javadoc Locations
20
expoint.target.name = Target Profiles
20
expoint.target.name = Target Profiles
21
expoint.bundleClasspathResolvers.name = Bundle Classpath Resolvers
21
22
22
target.name.0 = Base RCP (with Source)
23
target.name.0 = Base RCP (with Source)
23
target.name.1 = Base RCP (Binary Only)
24
target.name.1 = Base RCP (Binary Only)
(-)plugin.xml (+2 lines)
Lines 15-20 Link Here
15
     <extension-point id="source" name="%expoint.source.name" schema="schema/source.exsd"/>
15
     <extension-point id="source" name="%expoint.source.name" schema="schema/source.exsd"/>
16
     <extension-point id="javadoc" name="%expoint.javadoc.name" schema="schema/javadoc.exsd"/>
16
     <extension-point id="javadoc" name="%expoint.javadoc.name" schema="schema/javadoc.exsd"/>
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="bundleClasspathResolvers" name="%expoint.bundleClasspathResolvers.name" schema="schema/bundleClasspathResolvers.exsd"/>
19
18
   <extension
20
   <extension
19
         point="org.eclipse.jdt.core.classpathVariableInitializer">
21
         point="org.eclipse.jdt.core.classpathVariableInitializer">
20
      <classpathVariableInitializer
22
      <classpathVariableInitializer
(-)schema/bundleClasspathResolvers.exsd (+125 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="bundleClasspathResolvers" name="Bundle Classpath Resolver"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point allows clients to add bundle classpath entries and source lookup path entries locations and source lookup path.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="resolver" minOccurs="0" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="resolver">
51
      <complexType>
52
         <attribute name="nature" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  Nature of the projects this resolver is enabled for.
56
               </documentation>
57
            </annotation>
58
         </attribute>
59
         <attribute name="class" type="string" use="required">
60
            <annotation>
61
               <documentation>
62
                  The class that implements this dynamic bundle classpath entry resolver. The class must implement &lt;code&gt;IBundleClasspathResolver&lt;/code&gt;
63
               </documentation>
64
               <appInfo>
65
                  <meta.attribute kind="java" basedOn=":org.eclipse.pde.core.IBundleClasspathResolver"/>
66
               </appInfo>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         3.8
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         The following is an example of a classpath provider: 
87
88
&lt;p&gt;
89
&lt;pre&gt;
90
  &lt;extension
91
        point=&quot;org.eclipse.pde.core.bundleClasspathResolvers&quot;&gt;
92
     &lt;resolver
93
           class=&quot;org.eclipse.example.pde.SomeResolver&quot;
94
           nature=&quot;org.eclipse.example.projectNature&quot;&gt;
95
     &lt;/resolver&gt;
96
  &lt;/extension&gt;
97
&lt;/pre&gt;
98
&lt;/p&gt;
99
      </documentation>
100
   </annotation>
101
102
   <annotation>
103
      <appInfo>
104
         <meta.section type="apiinfo"/>
105
      </appInfo>
106
      <documentation>
107
         Each classpath resolver must provide a class that implements &lt;code&gt;org.eclipse.pde.core.IBundleClasspathResolver&lt;/code&gt; interface.
108
      </documentation>
109
   </annotation>
110
111
112
   <annotation>
113
      <appInfo>
114
         <meta.section type="copyright"/>
115
      </appInfo>
116
      <documentation>
117
         Copyright (c) 2011 Sonatype, Inc. and others.&lt;br&gt;
118
All rights reserved. This program and the accompanying materials
119
are made available under the terms of the Eclipse Public License v1.0
120
which accompanies this distribution, and is available at
121
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
122
      </documentation>
123
   </annotation>
124
125
</schema>
(-)src/org/eclipse/pde/core/IBundleClasspathResolver.java (+70 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Sonatype, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *      Sonatype, Inc. - initial API and implementation
10
 *      IBM Corporation - ongoing enhancements
11
 *******************************************************************************/
12
package org.eclipse.pde.core;
13
14
import java.util.Collection;
15
import java.util.Map;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.jdt.core.IJavaProject;
18
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
19
20
/**
21
 * Resolves dynamically generated bundle classpath entries in the context of a java project.
22
 * 
23
 * <p>
24
 * Generally, dynamically generated bundle classpath entries are not present under project
25
 * source tree but included in the bundle as part build process. During development time such bundle classpath entries
26
 * can be resolved to external jar files or workspace resources. Resolution of the
27
 * same entry may change over time, similarly to how Plug-in Dependencies classpath container can switch between 
28
 * external bundles and workspace projects.
29
 * </p>
30
 * 
31
 * <p>
32
 * A resolver is declared as an extension (<code>org.eclipse.pde.core.bundleClasspathResolvers</code>). This 
33
 * extension has the following attributes: 
34
 * <ul>
35
 * <li><code>nature</code> specified nature of the projects this resolver is registered for.</li>
36
 * <li><code>class</code> specifies the fully qualified name of the Java class that implements 
37
 *     <code>IBundleClasspathResolver</code>.</li>
38
 * </ul>
39
 * </p>
40
 * <p> 
41
 * The resolver is consulted when dynamically generated bundle is added to OSGi runtime launch and when looking up 
42
 * sources from the bundle.
43
 * </p>
44
 * 
45
 * @since 3.8
46
 */
47
public interface IBundleClasspathResolver {
48
49
	/**
50
	 * Returns a possibly empty map describing additional bundle classpath entries for a project in the workspace.
51
	 * 
52
	 * <p>The map key is a {@link IPath} describing the project relative path to a source directory or library.  The value
53
	 * is the {@link Collection} of {@link IPath} locations (relative to the project or absolute) that should be added
54
	 * to the bundle classpath.</p>
55
	 * 
56
	 * @param javaProject the java project to collect classpath entries for
57
	 * @return additional entries to add to the bundle classpath. Map of IPath to Collection, possibly empty
58
	 */
59
	public Map/*<IPath, Collection<IPath>>*/getAdditionalClasspathEntries(IJavaProject javaProject);
60
61
	/**
62
	 * Returns a possibly empty collection listing additional classpath entries for the source lookup path of a project in the workspace.
63
	 * 
64
	 * <p>The {@link Collection} will contain {@link IRuntimeClasspathEntry} describing locations where source can be obtained from.</p>
65
	 * 
66
	 * @param javaProject the java project to collect source entries for
67
	 * @return additional entries for the source lookup path. Collection of IRuntimeClasspathEntry, possibly empty
68
	 */
69
	public Collection/*<IRuntimeClasspathEntry>*/getAdditionalSourceEntries(IJavaProject javaProject);
70
}
(-)src/org/eclipse/pde/internal/core/ClasspathContainerResolverManager.java (+58 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Sonatype, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *      Sonatype, Inc. - initial API and implementation
10
 *      IBM Corporation - ongoing enhancements
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.core;
13
14
import java.util.ArrayList;
15
import java.util.List;
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.pde.core.IBundleClasspathResolver;
19
20
/**
21
 * Manager for client contributed IBundleClasspathResolvers. Collects the resolvers from the <code>
22
 * org.eclipse.pde.core.bundleClasspathResolvers</code> extension point.  Classpath resolvers
23
 * can then be asked to provide additional bundle classpath and source lookup entries for a project.
24
 * 
25
 * @see IBundleClasspathResolver
26
 */
27
public class ClasspathContainerResolverManager {
28
29
	private static final String POINT_ID = "org.eclipse.pde.core.bundleClasspathResolvers"; //$NON-NLS-1$
30
	private static final String ATT_NATURE = "nature"; //$NON-NLS-1$
31
	private static final String ATT_CLASS = "class"; //$NON-NLS-1$
32
33
	/**
34
	 * Returns all classpath resolvers contributed via extension point that support the given project's nature.
35
	 * 
36
	 * @param project project to check nature of
37
	 * @return all classpath resolvers that support the nature, possibly empty
38
	 */
39
	public IBundleClasspathResolver[] getBundleClasspathResolvers(IProject project) {
40
		List result = new ArrayList();
41
42
		IExtensionRegistry registry = Platform.getExtensionRegistry();
43
		IConfigurationElement[] elements = registry.getConfigurationElementsFor(POINT_ID);
44
		for (int i = 0; i < elements.length; i++) {
45
			String attrNature = elements[i].getAttribute(ATT_NATURE);
46
			try {
47
				if (project.isNatureEnabled(attrNature)) {
48
					result.add(elements[i].createExecutableExtension(ATT_CLASS));
49
				}
50
			} catch (CoreException e) {
51
				PDECore.log(e.getStatus());
52
			}
53
		}
54
55
		return (IBundleClasspathResolver[]) result.toArray(new IBundleClasspathResolver[result.size()]);
56
	}
57
58
}
(-)src/org/eclipse/pde/internal/core/ClasspathHelper.java (-5 / +26 lines)
Lines 17-22 Link Here
17
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
18
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
19
import org.eclipse.jdt.core.*;
19
import org.eclipse.jdt.core.*;
20
import org.eclipse.pde.core.IBundleClasspathResolver;
20
import org.eclipse.pde.core.build.IBuild;
21
import org.eclipse.pde.core.build.IBuild;
21
import org.eclipse.pde.core.build.IBuildEntry;
22
import org.eclipse.pde.core.build.IBuildEntry;
22
import org.eclipse.pde.core.plugin.*;
23
import org.eclipse.pde.core.plugin.*;
Lines 199-206 Link Here
199
					list = new ArrayList();
200
					list = new ArrayList();
200
				list.add(output);
201
				list.add(output);
201
				map.put(source, list);
202
				map.put(source, list);
203
			}
204
		}
205
206
		// Add additional entries from contributed bundle classpath resolvers
207
		IBundleClasspathResolver[] resolvers = PDECore.getDefault().getClasspathContainerResolverManager().getBundleClasspathResolvers(project);
208
		for (int i = 0; i < resolvers.length; i++) {
209
			Map resolved = resolvers[i].getAdditionalClasspathEntries(jProject);
210
			Iterator resolvedIter = resolved.entrySet().iterator();
211
			while (resolvedIter.hasNext()) {
212
				Map.Entry resolvedEntry = (Map.Entry) resolvedIter.next();
213
				IPath ceSource = (IPath) resolvedEntry.getKey();
214
				ArrayList list = (ArrayList) map.get(ceSource);
215
				if (list == null) {
216
					list = new ArrayList();
217
					map.put(ceSource, list);
218
				}
219
				list.addAll((Collection) resolvedEntry.getValue());
202
			}
220
			}
203
		}
221
		}
222
204
		return map;
223
		return map;
205
	}
224
	}
206
225
Lines 213-221 Link Here
213
			for (int j = 0; j < resources.length; j++) {
232
			for (int j = 0; j < resources.length; j++) {
214
				IResource res = project.findMember(resources[j]);
233
				IResource res = project.findMember(resources[j]);
215
				if (res != null) {
234
				if (res != null) {
216
					ArrayList list = (ArrayList) classpathMap.get(res.getFullPath());
235
					Collection list = (Collection) classpathMap.get(res.getFullPath());
217
					if (list != null) {
236
					if (list != null) {
218
						ListIterator li = list.listIterator();
237
						Iterator li = list.iterator();
219
						while (li.hasNext())
238
						while (li.hasNext())
220
							paths.add(li.next());
239
							paths.add(li.next());
221
					}
240
					}
Lines 231-241 Link Here
231
			IResource res = project.findMember(libName);
250
			IResource res = project.findMember(libName);
232
			if (res != null)
251
			if (res != null)
233
				path = res.getFullPath();
252
				path = res.getFullPath();
253
			else
254
				path = new Path(libName);
234
		}
255
		}
235
256
236
		ArrayList list = (ArrayList) classpathMap.get(path);
257
		Collection list = (Collection) classpathMap.get(path);
237
		if (list != null) {
258
		if (list != null) {
238
			ListIterator li = list.listIterator();
259
			Iterator li = list.iterator();
239
			while (li.hasNext())
260
			while (li.hasNext())
240
				paths.add(li.next());
261
				paths.add(li.next());
241
		}
262
		}
Lines 271-277 Link Here
271
									Iterator iterator = classpathMap.values().iterator();
292
									Iterator iterator = classpathMap.values().iterator();
272
									List collect = new ArrayList();
293
									List collect = new ArrayList();
273
									while (iterator.hasNext()) {
294
									while (iterator.hasNext()) {
274
										ArrayList list = (ArrayList) iterator.next();
295
										Collection list = (Collection) iterator.next();
275
										collect.addAll(list);
296
										collect.addAll(list);
276
									}
297
									}
277
									paths = (IPath[]) collect.toArray(new IPath[collect.size()]);
298
									paths = (IPath[]) collect.toArray(new IPath[collect.size()]);
(-)src/org/eclipse/pde/internal/core/PDECore.java (-1 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
import org.eclipse.core.resources.*;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.jdt.launching.JavaRuntime;
19
import org.eclipse.jdt.launching.JavaRuntime;
20
import org.eclipse.pde.core.IBundleClasspathResolver;
20
import org.eclipse.pde.core.plugin.IPluginModelBase;
21
import org.eclipse.pde.core.plugin.IPluginModelBase;
21
import org.eclipse.pde.core.project.IBundleProjectService;
22
import org.eclipse.pde.core.project.IBundleProjectService;
22
import org.eclipse.pde.internal.core.builders.FeatureRebuilder;
23
import org.eclipse.pde.internal.core.builders.FeatureRebuilder;
Lines 130-135 Link Here
130
	private SourceLocationManager fSourceLocationManager;
131
	private SourceLocationManager fSourceLocationManager;
131
	private JavadocLocationManager fJavadocLocationManager;
132
	private JavadocLocationManager fJavadocLocationManager;
132
	private SearchablePluginsManager fSearchablePluginsManager;
133
	private SearchablePluginsManager fSearchablePluginsManager;
134
	private ClasspathContainerResolverManager fClasspathContainerResolverManager;
133
135
134
	// Tracing options manager
136
	// Tracing options manager
135
	private TracingOptionsManager fTracingOptionsManager;
137
	private TracingOptionsManager fTracingOptionsManager;
Lines 215-220 Link Here
215
		return fSourceLocationManager;
217
		return fSourceLocationManager;
216
	}
218
	}
217
219
220
	/**
221
	 * Returns the singleton instance of the classpath container resolver manager used to dynamically
222
	 * resolve a project's classpath. Clients may contribute a {@link IBundleClasspathResolver} to the
223
	 * manager through the <code>org.eclipse.pde.core.bundleClasspathResolvers</code> extension.
224
	 * 
225
	 * @return singleton instance of the classpath container resolver manager
226
	 */
227
	public synchronized ClasspathContainerResolverManager getClasspathContainerResolverManager() {
228
		if (fClasspathContainerResolverManager == null) {
229
			fClasspathContainerResolverManager = new ClasspathContainerResolverManager();
230
		}
231
		return fClasspathContainerResolverManager;
232
	}
233
218
	public synchronized JavadocLocationManager getJavadocLocationManager() {
234
	public synchronized JavadocLocationManager getJavadocLocationManager() {
219
		if (fJavadocLocationManager == null)
235
		if (fJavadocLocationManager == null)
220
			fJavadocLocationManager = new JavadocLocationManager();
236
			fJavadocLocationManager = new JavadocLocationManager();
(-)src/org/eclipse/pde/internal/launching/sourcelookup/PDESourceLookupDirector.java (-5 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-17 Link Here
10
 *     Code 9 Corporation - ongoing enhancements
10
 *     Code 9 Corporation - ongoing enhancements
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.launching.sourcelookup;
12
package org.eclipse.pde.internal.launching.sourcelookup;
13
14
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
15
13
16
import java.io.File;
14
import java.io.File;
17
import java.util.*;
15
import java.util.*;
Lines 25-33 Link Here
25
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
23
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
26
import org.eclipse.jdt.launching.JavaRuntime;
24
import org.eclipse.jdt.launching.JavaRuntime;
27
import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
25
import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
26
import org.eclipse.pde.core.IBundleClasspathResolver;
28
import org.eclipse.pde.core.plugin.*;
27
import org.eclipse.pde.core.plugin.*;
29
import org.eclipse.pde.internal.core.PDEClasspathContainer;
28
import org.eclipse.pde.internal.core.*;
30
import org.eclipse.pde.internal.core.TargetPlatformHelper;
29
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
31
30
32
public class PDESourceLookupDirector extends AbstractSourceLookupDirector {
31
public class PDESourceLookupDirector extends AbstractSourceLookupDirector {
33
32
Lines 209-214 Link Here
209
					result.add(rte);
208
					result.add(rte);
210
			}
209
			}
211
		}
210
		}
211
212
		// Add additional entries from contributed classpath container resolvers
213
		IBundleClasspathResolver[] resolvers = PDECore.getDefault().getClasspathContainerResolverManager().getBundleClasspathResolvers(project);
214
		for (int i = 0; i < resolvers.length; i++) {
215
			result.addAll(resolvers[i].getAdditionalSourceEntries(jProject));
216
		}
212
	}
217
	}
213
218
214
	/* (non-Javadoc)
219
	/* (non-Javadoc)

Return to bug 353442