|
Lines 59-82
Link Here
|
| 59 |
} |
59 |
} |
| 60 |
|
60 |
|
| 61 |
public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, boolean clear) throws CoreException { |
61 |
public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, boolean clear) throws CoreException { |
| 62 |
|
62 |
IJavaProject javaProject = JavaCore.create(project); |
| 63 |
ArrayList result = new ArrayList(); |
63 |
ArrayList result = new ArrayList(); |
| 64 |
|
|
|
| 65 |
IBuild build = getBuild(project); |
64 |
IBuild build = getBuild(project); |
| 66 |
|
65 |
|
| 67 |
// add own libraries/source |
66 |
// add own libraries/source |
| 68 |
addSourceAndLibraries(project, model, build, clear, result); |
67 |
addSourceAndLibraries(project, model, build, clear, result); |
| 69 |
|
68 |
|
| 70 |
// add JRE and set compliance options |
69 |
// add JRE and set compliance options |
| 71 |
String ee = getExecutionEnvironment(model.getBundleDescription()); |
70 |
String ee = getExecutionEnvironment(model.getBundleDescription()); |
| 72 |
result.add(createJREEntry(ee)); |
71 |
result.add(createJREEntryUsingPreviousEntry(javaProject, ee)); |
| 73 |
setComplianceOptions(JavaCore.create(project), ExecutionEnvironmentAnalyzer.getCompliance(ee)); |
72 |
setComplianceOptions(JavaCore.create(project), ExecutionEnvironmentAnalyzer.getCompliance(ee)); |
| 74 |
|
73 |
|
| 75 |
// add pde container |
74 |
// add pde container |
| 76 |
result.add(createContainerEntry()); |
75 |
result.add(createContainerEntry()); |
| 77 |
|
76 |
|
| 78 |
IClasspathEntry[] entries = (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]); |
77 |
IClasspathEntry[] entries = (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]); |
| 79 |
IJavaProject javaProject = JavaCore.create(project); |
|
|
| 80 |
IJavaModelStatus validation = |
78 |
IJavaModelStatus validation = |
| 81 |
JavaConventions.validateClasspath( |
79 |
JavaConventions.validateClasspath( |
| 82 |
javaProject, |
80 |
javaProject, |
|
Lines 295-302
Link Here
|
| 295 |
} |
293 |
} |
| 296 |
} |
294 |
} |
| 297 |
|
295 |
|
|
|
296 |
/** |
| 297 |
* Returns a new classpath container entry for the given execution environment. If the given java project |
| 298 |
* has an existing JRE/EE classpath entry, the access rules, extra attributes and isExported settings of |
| 299 |
* the existing entry will be added to the new execution entry. |
| 300 |
* |
| 301 |
* @param javaProject project to check for existing JRE/EE classpath entries |
| 302 |
* @param ee id of the execution environment to create an entry for |
| 303 |
* @return new classpath container entry |
| 304 |
* @throws CoreException if there is a problem accessing the classpath entries of the project |
| 305 |
*/ |
| 306 |
public static IClasspathEntry createJREEntryUsingPreviousEntry(IJavaProject javaProject, String ee) throws CoreException { |
| 307 |
IClasspathEntry existingEntry = null; |
| 308 |
IClasspathEntry[] entries = javaProject.getRawClasspath(); |
| 309 |
for (int i = 0; i < entries.length; i++) { |
| 310 |
if (entries[i].getPath().segment(0).equals(JavaRuntime.JRE_CONTAINER)){ |
| 311 |
existingEntry = entries[i]; |
| 312 |
break; |
| 313 |
} |
| 314 |
} |
| 315 |
if (existingEntry == null){ |
| 316 |
return createJREEntry(ee); |
| 317 |
} |
| 318 |
return JavaCore.newContainerEntry(getEEPath(ee), existingEntry.getAccessRules(), existingEntry.getExtraAttributes(), existingEntry.isExported()); |
| 319 |
} |
| 298 |
|
320 |
|
|
|
321 |
/** |
| 322 |
* Returns a classpath container entry for the given execution environment. |
| 323 |
* @param ee id of the execution environment |
| 324 |
* @return classpath container entry |
| 325 |
*/ |
| 299 |
public static IClasspathEntry createJREEntry(String ee) { |
326 |
public static IClasspathEntry createJREEntry(String ee) { |
|
|
327 |
return JavaCore.newContainerEntry(getEEPath(ee)); |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* Returns the JRE container path for the execution environment with the given id. |
| 332 |
* @param ee execution environment id |
| 333 |
* @return JRE container path for the execution environment |
| 334 |
*/ |
| 335 |
private static IPath getEEPath(String ee){ |
| 300 |
IPath path = null; |
336 |
IPath path = null; |
| 301 |
if (ee != null) { |
337 |
if (ee != null) { |
| 302 |
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); |
338 |
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager(); |
|
Lines 304-314
Link Here
|
| 304 |
if (env != null) |
340 |
if (env != null) |
| 305 |
path = JavaRuntime.newJREContainerPath(env); |
341 |
path = JavaRuntime.newJREContainerPath(env); |
| 306 |
} |
342 |
} |
| 307 |
if (path == null) |
343 |
if (path == null){ |
| 308 |
path = JavaRuntime.newDefaultJREContainerPath(); |
344 |
path = JavaRuntime.newDefaultJREContainerPath(); |
| 309 |
return JavaCore.newContainerEntry(path); |
345 |
} |
|
|
346 |
return path; |
| 310 |
} |
347 |
} |
| 311 |
|
348 |
|
|
|
349 |
/** |
| 350 |
* @return a new classpath container entry for a required plugin container |
| 351 |
*/ |
| 312 |
public static IClasspathEntry createContainerEntry() { |
352 |
public static IClasspathEntry createContainerEntry() { |
| 313 |
return JavaCore.newContainerEntry(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH); |
353 |
return JavaCore.newContainerEntry(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH); |
| 314 |
} |
354 |
} |