Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 154593 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/wizards/plugin/ClasspathComputer.java (-6 / +49 lines)
Lines 40-48 Link Here
40
	}
40
	}
41
41
42
	public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, boolean clear) throws CoreException {
42
	public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, boolean clear) throws CoreException {
43
43
		IJavaProject javaProject = JavaCore.create(project);
44
		ArrayList result = new ArrayList();
44
		ArrayList result = new ArrayList();
45
46
		IBuild build = getBuild(project);
45
		IBuild build = getBuild(project);
47
46
48
		// add own libraries/source
47
		// add own libraries/source
Lines 50-63 Link Here
50
49
51
		// add JRE and set compliance options
50
		// add JRE and set compliance options
52
		String ee = getExecutionEnvironment(model.getBundleDescription());
51
		String ee = getExecutionEnvironment(model.getBundleDescription());
53
		result.add(createJREEntry(ee));
52
		result.add(createJREEntryUsingPreviousEntry(javaProject, ee));
54
		setComplianceOptions(JavaCore.create(project), ExecutionEnvironmentAnalyzer.getCompliance(ee));
53
		setComplianceOptions(JavaCore.create(project), ExecutionEnvironmentAnalyzer.getCompliance(ee));
55
54
56
		// add pde container
55
		// add pde container
57
		result.add(createContainerEntry());
56
		result.add(createContainerEntry());
58
57
59
		IClasspathEntry[] entries = (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
58
		IClasspathEntry[] entries = (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
60
		IJavaProject javaProject = JavaCore.create(project);
61
		IJavaModelStatus validation = JavaConventions.validateClasspath(javaProject, entries, javaProject.getOutputLocation());
59
		IJavaModelStatus validation = JavaConventions.validateClasspath(javaProject, entries, javaProject.getOutputLocation());
62
		if (!validation.isOK()) {
60
		if (!validation.isOK()) {
63
			PDECore.logErrorMessage(validation.getMessage());
61
			PDECore.logErrorMessage(validation.getMessage());
Lines 275-281 Link Here
275
		}
273
		}
276
	}
274
	}
277
275
276
	/**
277
	 * Returns a new classpath container entry for the given execution environment.  If the given java project
278
	 * has an existing JRE/EE classpath entry, the access rules, extra attributes and isExported settings of
279
	 * the existing entry will be added to the new execution entry.
280
	 *  
281
	 * @param javaProject project to check for existing JRE/EE classpath entries
282
	 * @param ee id of the execution environment to create an entry for
283
	 * @return new classpath container entry
284
	 * @throws CoreException if there is a problem accessing the classpath entries of the project
285
	 */
286
	public static IClasspathEntry createJREEntryUsingPreviousEntry(IJavaProject javaProject, String ee) throws CoreException {
287
		IClasspathEntry existingEntry = null;
288
		IClasspathEntry[] entries = javaProject.getRawClasspath();
289
		for (int i = 0; i < entries.length; i++) {
290
			if (entries[i].getPath().segment(0).equals(JavaRuntime.JRE_CONTAINER)) {
291
				existingEntry = entries[i];
292
				break;
293
			}
294
		}
295
		IPath newPath = getEEPath(ee);
296
		if (existingEntry != null && existingEntry.getPath().equals(newPath)) {
297
			return JavaCore.newContainerEntry(getEEPath(ee), existingEntry.getAccessRules(), existingEntry.getExtraAttributes(), existingEntry.isExported());
298
		}
299
		return JavaCore.newContainerEntry(newPath);
300
301
	}
302
303
	/**
304
	 * Returns a classpath container entry for the given execution environment.
305
	 * @param ee id of the execution environment
306
	 * @return classpath container entry
307
	 */
278
	public static IClasspathEntry createJREEntry(String ee) {
308
	public static IClasspathEntry createJREEntry(String ee) {
309
		return JavaCore.newContainerEntry(getEEPath(ee));
310
	}
311
312
	/**
313
	 * Returns the JRE container path for the execution environment with the given id.
314
	 * @param ee execution environment id
315
	 * @return JRE container path for the execution environment
316
	 */
317
	private static IPath getEEPath(String ee) {
279
		IPath path = null;
318
		IPath path = null;
280
		if (ee != null) {
319
		if (ee != null) {
281
			IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
320
			IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
Lines 283-293 Link Here
283
			if (env != null)
322
			if (env != null)
284
				path = JavaRuntime.newJREContainerPath(env);
323
				path = JavaRuntime.newJREContainerPath(env);
285
		}
324
		}
286
		if (path == null)
325
		if (path == null) {
287
			path = JavaRuntime.newDefaultJREContainerPath();
326
			path = JavaRuntime.newDefaultJREContainerPath();
288
		return JavaCore.newContainerEntry(path);
327
		}
328
		return path;
289
	}
329
	}
290
330
331
	/**
332
	 * @return a new classpath container entry for a required plugin container
333
	 */
291
	public static IClasspathEntry createContainerEntry() {
334
	public static IClasspathEntry createContainerEntry() {
292
		return JavaCore.newContainerEntry(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH);
335
		return JavaCore.newContainerEntry(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH);
293
	}
336
	}

Return to bug 154593