Java Code Examples for org.eclipse.jdt.launching.JavaRuntime#getExecutionEnvironmentId()
The following examples show how to use
org.eclipse.jdt.launching.JavaRuntime#getExecutionEnvironmentId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComplianceConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IExecutionEnvironment getEE() { if (fProject == null) return null; try { IClasspathEntry[] entries= JavaCore.create(fProject).getRawClasspath(); for (int i= 0; i < entries.length; i++) { IClasspathEntry entry= entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { String eeId= JavaRuntime.getExecutionEnvironmentId(entry.getPath()); if (eeId != null) { return JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId); } } } } catch (CoreException e) { JavaPlugin.log(e); } return null; }
Example 2
Source File: BuildPathSupport.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Sets the default compiler compliance options iff <code>modifiedClassPathEntries</code> * contains a classpath container entry that is modified or new and that points to an execution * environment. Does nothing if the EE or the options could not be resolved. * * @param javaProject the Java project * @param modifiedClassPathEntries a list of {@link CPListElement} * * @see #getEEOptions(IExecutionEnvironment) * * @since 3.5 */ public static void setEEComplianceOptions(IJavaProject javaProject, List<CPListElement> modifiedClassPathEntries) { for (Iterator<CPListElement> iter= modifiedClassPathEntries.iterator(); iter.hasNext();) { CPListElement entry= iter.next(); if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IPath path= entry.getPath(); if (! path.equals(entry.getOrginalPath())) { String eeID= JavaRuntime.getExecutionEnvironmentId(path); if (eeID != null) { setEEComplianceOptions(javaProject, eeID, null); return; } } } } }
Example 3
Source File: JavaProjectFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override protected void enhanceProject(IProject project, SubMonitor monitor, Shell shell) throws CoreException { super.enhanceProject(project, monitor, shell); if (builderIds.contains(JavaCore.BUILDER_ID)) { SubMonitor subMonitor = SubMonitor.convert(monitor, 10); try { subMonitor.subTask(Messages.JavaProjectFactory_ConfigureJavaProject + projectName); IJavaProject javaProject = JavaCore.create(project); List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>(); for (final IProject referencedProject : project.getReferencedProjects()) { final IClasspathEntry referencedProjectClasspathEntry = JavaCore.newProjectEntry(referencedProject .getFullPath()); classpathEntries.add(referencedProjectClasspathEntry); } for (final String folderName : getFolders()) { final IFolder sourceFolder = project.getFolder(folderName); String outputFolderName = sourceFolderOutputs.get(folderName); final IClasspathEntry srcClasspathEntry = JavaCore.newSourceEntry(sourceFolder.getFullPath(), ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, outputFolderName == null ? null : project.getFolder(outputFolderName).getFullPath(), testSourceFolders.contains(folderName) ? new IClasspathAttribute[] { JavaCore.newClasspathAttribute("test", "true") } : new IClasspathAttribute[0]); classpathEntries.add(srcClasspathEntry); } classpathEntries.addAll(extraClasspathEntries); IClasspathEntry defaultJREContainerEntry = getJreContainerEntry(); classpathEntries.add(defaultJREContainerEntry); addMoreClasspathEntriesTo(classpathEntries); javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), subMonitor.newChild(1)); javaProject.setOutputLocation(new Path("/" + project.getName() + "/" + defaultOutput), subMonitor.newChild(1)); String executionEnvironmentId = JavaRuntime.getExecutionEnvironmentId(defaultJREContainerEntry.getPath()); if (executionEnvironmentId != null) { BuildPathSupport.setEEComplianceOptions(javaProject, executionEnvironmentId, null); } } catch (JavaModelException e) { logger.error(e.getMessage(), e); } } }