List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_CONTAINER
int CPE_CONTAINER
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_CONTAINER.
Click Source Link
From source file:com.redhat.ceylon.eclipse.core.model.JDTModelLoader.java
License:Open Source License
@Override public synchronized boolean loadPackage(Module module, String packageName, boolean loadDeclarations) { packageName = Util.quoteJavaKeywords(packageName); if (loadDeclarations && !loadedPackages.add(cacheKeyByModule(module, packageName))) { return true; }//ww w . j av a 2 s . co m if (module instanceof JDTModule) { JDTModule jdtModule = (JDTModule) module; List<IPackageFragmentRoot> roots = jdtModule.getPackageFragmentRoots(); IPackageFragment packageFragment = null; for (IPackageFragmentRoot root : roots) { // skip packages that are not present if (!root.exists() || !javaProject.isOnClasspath(root)) continue; try { IClasspathEntry entry = root.getRawClasspathEntry(); //TODO: is the following really necessary? //Note that getContentKind() returns an undefined //value for a classpath container or variable if (entry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE && entry.getContentKind() == IPackageFragmentRoot.K_SOURCE && !CeylonBuilder.isCeylonSourceEntry(entry)) { continue; } packageFragment = root.getPackageFragment(packageName); if (!packageFragment.exists()) { continue; } } catch (JavaModelException e) { if (!e.isDoesNotExist()) { e.printStackTrace(); } continue; } if (!loadDeclarations) { // we found the package return true; } // we have a few virtual types in java.lang that we need to load but they are not listed from class files if (module.getNameAsString().equals(JAVA_BASE_MODULE_NAME) && packageName.equals("java.lang")) { loadJavaBaseArrays(); } IClassFile[] classFiles = new IClassFile[] {}; org.eclipse.jdt.core.ICompilationUnit[] compilationUnits = new org.eclipse.jdt.core.ICompilationUnit[] {}; try { classFiles = packageFragment.getClassFiles(); } catch (JavaModelException e) { e.printStackTrace(); } try { compilationUnits = packageFragment.getCompilationUnits(); } catch (JavaModelException e) { e.printStackTrace(); } List<IType> typesToLoad = new LinkedList<>(); for (IClassFile classFile : classFiles) { IType type = classFile.getType(); typesToLoad.add(type); } for (org.eclipse.jdt.core.ICompilationUnit compilationUnit : compilationUnits) { // skip removed CUs if (!compilationUnit.exists()) continue; try { for (IType type : compilationUnit.getTypes()) { typesToLoad.add(type); } } catch (JavaModelException e) { e.printStackTrace(); } } for (IType type : typesToLoad) { String typeFullyQualifiedName = type.getFullyQualifiedName(); String[] nameParts = typeFullyQualifiedName.split("\\."); String typeQualifiedName = nameParts[nameParts.length - 1]; // only top-levels are added in source declarations if (typeQualifiedName.indexOf('$') > 0) { continue; } if (type.exists() && !sourceDeclarations.containsKey(getToplevelQualifiedName( type.getPackageFragment().getElementName(), typeFullyQualifiedName)) && !isTypeHidden(module, typeFullyQualifiedName)) { convertToDeclaration(module, typeFullyQualifiedName, DeclarationType.VALUE); } } } } return false; }
From source file:com.redhat.ceylon.eclipse.core.model.JDTModule.java
License:Open Source License
public synchronized List<IPackageFragmentRoot> getPackageFragmentRoots() { if (packageFragmentRoots.isEmpty() && !moduleManager.isExternalModuleLoadedFromSource(getNameAsString())) { IJavaProject javaProject = moduleManager.getJavaProject(); if (javaProject != null) { if (this.equals(getLanguageModule())) { IClasspathEntry runtimeClasspathEntry = null; try { for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().segment(0) .equals(CeylonLanguageModuleContainer.CONTAINER_ID)) { runtimeClasspathEntry = entry; break; }//from ww w . ja v a 2 s. co m } if (runtimeClasspathEntry != null) { for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { if (root.exists() && javaProject.isOnClasspath(root) && root.getRawClasspathEntry().equals(runtimeClasspathEntry)) { packageFragmentRoots.add(root); } } } } catch (JavaModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { File jarToSearch = null; try { jarToSearch = returnCarFile(); if (jarToSearch == null) { RepositoryManager repoMgr = CeylonBuilder .getProjectRepositoryManager(javaProject.getProject()); if (repoMgr != null) { jarToSearch = CeylonProjectModulesContainer.getModuleArtifact(repoMgr, this); } } if (jarToSearch != null) { IPackageFragmentRoot root = moduleManager.getJavaProject() .getPackageFragmentRoot(jarToSearch.toString()); if (root instanceof JarPackageFragmentRoot) { JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) root; if (jarRoot.getJar().getName().equals(jarToSearch.getPath())) { packageFragmentRoots.add(root); } } } } catch (CoreException e) { if (jarToSearch != null) { System.err.println("Exception trying to get Jar file '" + jarToSearch + "' :"); } e.printStackTrace(); } } } } return packageFragmentRoots; }
From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTModelLoader.java
License:Open Source License
@Override public synchronized boolean loadPackage(String packageName, boolean loadDeclarations) { packageName = Util.quoteJavaKeywords(packageName); if (loadDeclarations && !loadedPackages.add(packageName)) { return true; }//from w ww .j a v a 2 s. c o m Module module = lookupModuleInternal(packageName); if (module instanceof JDTModule) { JDTModule jdtModule = (JDTModule) module; List<IPackageFragmentRoot> roots = jdtModule.getPackageFragmentRoots(); IPackageFragment packageFragment = null; for (IPackageFragmentRoot root : roots) { // skip packages that are not present if (!root.exists()) continue; try { IClasspathEntry entry = root.getRawClasspathEntry(); //TODO: is the following really necessary? //Note that getContentKind() returns an undefined //value for a classpath container or variable if (entry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE && entry.getContentKind() == IPackageFragmentRoot.K_SOURCE && !CeylonBuilder.isCeylonSourceEntry(entry)) { continue; } packageFragment = root.getPackageFragment(packageName); if (packageFragment.exists()) { if (!loadDeclarations) { // we found the package return true; } else { try { for (IClassFile classFile : packageFragment.getClassFiles()) { // skip removed class files if (!classFile.exists()) continue; IType type = classFile.getType(); if (type.exists() && !type.isMember() && !sourceDeclarations.containsKey( getQualifiedName(type.getPackageFragment().getElementName(), type.getTypeQualifiedName()))) { convertToDeclaration(type.getFullyQualifiedName(), DeclarationType.VALUE); } } for (org.eclipse.jdt.core.ICompilationUnit compilationUnit : packageFragment .getCompilationUnits()) { // skip removed CUs if (!compilationUnit.exists()) continue; for (IType type : compilationUnit.getTypes()) { if (type.exists() && !type.isMember() && !sourceDeclarations.containsKey( getQualifiedName(type.getPackageFragment().getElementName(), type.getTypeQualifiedName()))) { convertToDeclaration(type.getFullyQualifiedName(), DeclarationType.VALUE); } } } } catch (JavaModelException e) { e.printStackTrace(); } } } } catch (JavaModelException e) { e.printStackTrace(); } } } return false; }
From source file:com.siteview.mde.internal.core.builders.BundleErrorReporter.java
License:Open Source License
private void validateRequiredExecutionEnvironment() { int sev = CompilerFlags.getFlag(fProject, CompilerFlags.P_INCOMPATIBLE_ENV); if (sev == CompilerFlags.IGNORE) return;//from w w w. j ava2s .c om BundleDescription desc = fModel.getBundleDescription(); if (desc == null) return; // if we aren't a java project, let's not check for a BREE try { if (!fProject.hasNature(JavaCore.NATURE_ID)) return; } catch (CoreException e) { return; } String[] bundleEnvs = desc.getExecutionEnvironments(); if (bundleEnvs == null || bundleEnvs.length == 0) { // No EE specified IJavaProject javaProject = JavaCore.create(fProject); // See if the project has an EE classpath entry if (javaProject.exists()) { try { IClasspathEntry[] entries = javaProject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IPath currentPath = entries[i].getPath(); if (JavaRuntime.newDefaultJREContainerPath().matchingFirstSegments(currentPath) > 0) { String eeId = JavaRuntime.getExecutionEnvironmentId(currentPath); if (eeId != null) { IMarker marker = report( MDECoreMessages.BundleErrorReporter_noExecutionEnvironmentSet, 1, sev, MDEMarkerFactory.M_EXECUTION_ENVIRONMENT_NOT_SET, MDEMarkerFactory.CAT_EE); addMarkerAttribute(marker, "ee_id", eeId); //$NON-NLS-1$ return; } } } } } catch (JavaModelException e) { MDECore.log(e); } } // If no EE classpath entry, get a matching EE for the project JRE (or the default JRE) IExecutionEnvironment[] systemEnvs = JavaRuntime.getExecutionEnvironmentsManager() .getExecutionEnvironments(); IVMInstall vm = JavaRuntime.getDefaultVMInstall(); if (javaProject.exists()) { try { vm = JavaRuntime.getVMInstall(javaProject); } catch (CoreException e) { MDECore.log(e); } } if (vm != null) { for (int i = 0; i < systemEnvs.length; i++) { // Get strictly compatible EE for the default VM if (systemEnvs[i].isStrictlyCompatible(vm)) { IMarker marker = report(MDECoreMessages.BundleErrorReporter_noExecutionEnvironmentSet, 1, sev, MDEMarkerFactory.M_EXECUTION_ENVIRONMENT_NOT_SET, MDEMarkerFactory.CAT_EE); addMarkerAttribute(marker, "ee_id", systemEnvs[i].getId()); //$NON-NLS-1$ break; } } } return; } IHeader header = getHeader(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT); if (header == null) return; IExecutionEnvironment env = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(bundleEnvs[0]); if (env != null) { IJavaProject jproject = JavaCore.create(fProject); IClasspathEntry[] entries; try { entries = jproject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { if (entries[i].getEntryKind() != IClasspathEntry.CPE_CONTAINER) continue; IPath currentPath = entries[i].getPath(); if (JavaRuntime.newDefaultJREContainerPath().matchingFirstSegments(currentPath) == 0) continue; IPath validPath = JavaRuntime.newJREContainerPath(env); if (!validPath.equals(currentPath)) { // Check if the user is using a perfect match JRE IVMInstall vm = JavaRuntime.getVMInstall(currentPath); if (vm == null || !env.isStrictlyCompatible(vm)) { report(NLS.bind(MDECoreMessages.BundleErrorReporter_reqExecEnv_conflict, bundleEnvs[0]), getLine(header, bundleEnvs[0]), sev, MDEMarkerFactory.M_MISMATCHED_EXEC_ENV, MDEMarkerFactory.CAT_EE); } } } } catch (JavaModelException e) { } } IExecutionEnvironment[] systemEnvs = JavaRuntime.getExecutionEnvironmentsManager() .getExecutionEnvironments(); for (int i = 0; i < bundleEnvs.length; i++) { boolean found = false; for (int j = 0; j < systemEnvs.length; j++) { if (bundleEnvs[i].equals(systemEnvs[j].getId())) { found = true; break; } } if (!found) { report(NLS.bind(MDECoreMessages.BundleErrorReporter_reqExecEnv_unknown, bundleEnvs[i]), getLine(header, bundleEnvs[i]), sev, MDEMarkerFactory.M_UNKNOW_EXEC_ENV, MDEMarkerFactory.CAT_EE); break; } } }
From source file:com.siteview.mde.internal.core.JavaElementChangeListener.java
License:Open Source License
private boolean ignoreDelta(IJavaElementDelta delta) { try {//from w ww . j a v a 2s . c o m IJavaElement element = delta.getElement(); if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; IClasspathEntry entry = root.getRawClasspathEntry(); if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) return true; } } catch (JavaModelException e) { } return false; }
From source file:com.siteview.mde.internal.core.project.ProjectModifyOperation.java
License:Open Source License
/** * Creates or modifies a project based on the given description. * /*from w ww. ja va2 s.c o m*/ * @param monitor progress monitor or <code>null</code> * @param description project description * @throws CoreException if project creation fails */ public void execute(IProgressMonitor monitor, IBundleProjectDescription description) throws CoreException { // retrieve current description of the project to detect differences IProject project = description.getProject(); IBundleProjectService service = (IBundleProjectService) MDECore.getDefault() .acquireService(IBundleProjectService.class.getName()); IBundleProjectDescription before = service.getDescription(project); boolean considerRoot = !project.exists(); String taskName = null; boolean jpExisted = false; if (project.exists()) { taskName = Messages.ProjectModifyOperation_0; jpExisted = before.hasNature(JavaCore.NATURE_ID); } else { taskName = Messages.ProjectModifyOperation_1; // new bundle projects get Java and Plug-in natures if (description.getNatureIds().length == 0) { description .setNatureIds(new String[] { IBundleProjectDescription.PLUGIN_NATURE, JavaCore.NATURE_ID }); } } boolean becomeBundle = !before.hasNature(IBundleProjectDescription.PLUGIN_NATURE) && description.hasNature(IBundleProjectDescription.PLUGIN_NATURE); // set default values when migrating from Java project to bundle project if (jpExisted && becomeBundle) { if (description.getExecutionEnvironments() == null) { // use EE from Java project when unspecified in the description, and a bundle nature is being added IJavaProject jp = JavaCore.create(project); if (jp.exists()) { IClasspathEntry[] classpath = jp.getRawClasspath(); for (int i = 0; i < classpath.length; i++) { IClasspathEntry entry = classpath[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { String id = JavaRuntime.getExecutionEnvironmentId(entry.getPath()); if (id != null) { description.setExecutionEnvironments(new String[] { id }); break; } } } } } } // other default values when becoming a bundle if (becomeBundle) { // set default values for where unspecified if (description.getBundleVersion() == null) { description.setBundleVersion(new Version(1, 0, 0, "qualifier")); //$NON-NLS-1$ } } SubMonitor sub = SubMonitor.convert(monitor, taskName, 6); // create and open project createProject(description); // set bundle root for new projects if (considerRoot) { IFolder folder = null; IPath root = description.getBundleRoot(); if (root != null && !root.isEmpty()) { folder = project.getFolder(root); CoreUtility.createFolder(folder); } PDEProject.setBundleRoot(project, folder); } sub.worked(1); configureNatures(description); sub.worked(1); if (project.hasNature(JavaCore.NATURE_ID)) { configureJavaProject(description, before, jpExisted); } sub.worked(1); configureManifest(description, before); sub.worked(1); configureBuildPropertiesFile(description, before); sub.worked(1); // project settings for Equinox, Extension Registry, Automated dependency policy, // manifest editor launch shortcuts and export wizard IEclipsePreferences pref = new ProjectScope(project).getNode(MDECore.PLUGIN_ID); if (pref != null) { // best guess for automated dependency management: Equinox + Extensions = use required bundle if (description.isEquinox() && description.isExtensionRegistry()) { pref.remove(ICoreConstants.RESOLVE_WITH_REQUIRE_BUNDLE); // i.e. use required bundle } else { pref.putBoolean(ICoreConstants.RESOLVE_WITH_REQUIRE_BUNDLE, false); } if (description.isExtensionRegistry()) { pref.remove(ICoreConstants.EXTENSIONS_PROPERTY); // i.e. support extensions } else { pref.putBoolean(ICoreConstants.EXTENSIONS_PROPERTY, false); } if (description.isEquinox()) { pref.remove(ICoreConstants.EQUINOX_PROPERTY); // i.e. using Equinox } else { pref.putBoolean(ICoreConstants.EQUINOX_PROPERTY, false); } String[] shorts = description.getLaunchShortcuts(); if (shorts == null || shorts.length == 0) { pref.remove(ICoreConstants.MANIFEST_LAUNCH_SHORTCUTS); // use defaults } else { StringBuffer value = new StringBuffer(); for (int i = 0; i < shorts.length; i++) { if (i > 0) { value.append(','); } value.append(shorts[i]); } pref.put(ICoreConstants.MANIFEST_LAUNCH_SHORTCUTS, value.toString()); } if (description.getExportWizardId() == null) { pref.remove(ICoreConstants.MANIFEST_EXPORT_WIZARD); } else { pref.put(ICoreConstants.MANIFEST_EXPORT_WIZARD, description.getExportWizardId()); } try { pref.flush(); } catch (BackingStoreException e) { throw new CoreException( new Status(IStatus.ERROR, MDECore.PLUGIN_ID, Messages.ProjectModifyOperation_2, e)); } } if (fModel.isDirty()) { fModel.save(); } sub.worked(1); sub.done(); if (monitor != null) { monitor.done(); } }
From source file:com.siteview.mde.internal.core.project.ProjectModifyOperation.java
License:Open Source License
/** * Configures the build path and output location of the described Java project. * If the Java project existed before this operation, new build path entries are * added for the bundle class path, if required, but we don't change the exiting * build path.// w ww . j av a 2 s . c o m * * @param description desired project description * @param before state before the operation * @param existed whether the Java project existed before the operation */ private void configureJavaProject(IBundleProjectDescription description, IBundleProjectDescription before, boolean existed) throws CoreException { IProject project = description.getProject(); IJavaProject javaProject = JavaCore.create(project); // create source folders as required IBundleClasspathEntry[] bces = description.getBundleClasspath(); if (bces != null && bces.length > 0) { for (int i = 0; i < bces.length; i++) { IPath folder = bces[i].getSourcePath(); if (folder != null) { CoreUtility.createFolder(project.getFolder(folder)); } } } // Set default output folder if (description.getDefaultOutputFolder() != null) { IPath path = project.getFullPath().append(description.getDefaultOutputFolder()); javaProject.setOutputLocation(path, null); } // merge the class path if the project existed before IBundleClasspathEntry[] prev = before.getBundleClasspath(); if (!isEqual(bces, prev)) { if (existed) { // add entries not already present IClasspathEntry[] entries = getSourceFolderEntries(javaProject, description); IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); List add = new ArrayList(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; boolean present = false; for (int j = 0; j < rawClasspath.length; j++) { IClasspathEntry existingEntry = rawClasspath[j]; if (existingEntry.getEntryKind() == entry.getEntryKind()) { if (existingEntry.getPath().equals(entry.getPath())) { present = true; break; } } } if (!present) { add.add(entry); } } // check if the 'required plug-ins' container is present boolean addRequired = false; if (description.hasNature(IBundleProjectDescription.PLUGIN_NATURE)) { addRequired = true; for (int i = 0; i < rawClasspath.length; i++) { IClasspathEntry cpe = rawClasspath[i]; if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (MDECore.REQUIRED_PLUGINS_CONTAINER_PATH.equals(cpe.getPath())) { addRequired = false; break; } } } } if (addRequired) { add.add(ClasspathComputer.createContainerEntry()); } if (!add.isEmpty()) { List all = new ArrayList(); for (int i = 0; i < rawClasspath.length; i++) { all.add(rawClasspath[i]); } all.addAll(add); javaProject.setRawClasspath((IClasspathEntry[]) all.toArray(new IClasspathEntry[all.size()]), null); } } else { IClasspathEntry[] entries = getClassPathEntries(javaProject, description); javaProject.setRawClasspath(entries, null); } } }
From source file:com.siteview.mde.internal.ui.editor.monitor.LibrarySection.java
License:Open Source License
private void updateJavaClasspathLibs(String[] oldPaths, String[] newPaths) { IProject project = ((IModel) getPage().getModel()).getUnderlyingResource().getProject(); IJavaProject jproject = JavaCore.create(project); try {/*from w ww . j ava2s.co m*/ IClasspathEntry[] entries = jproject.getRawClasspath(); ArrayList toBeAdded = new ArrayList(); int index = -1; entryLoop: for (int i = 0; i < entries.length; i++) { if (entries[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { if (index == -1) index = i; // do not add the old paths (handling deletion/renaming) IPath path = entries[i].getPath().removeFirstSegments(1).removeTrailingSeparator(); for (int j = 0; j < oldPaths.length; j++) if (oldPaths[j] != null && path.equals(new Path(oldPaths[j]).removeTrailingSeparator())) continue entryLoop; } else if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) if (index == -1) index = i; toBeAdded.add(entries[i]); } if (index == -1) index = entries.length; // add paths for (int i = 0; i < newPaths.length; i++) { if (newPaths[i] == null) continue; IClasspathEntry entry = JavaCore.newLibraryEntry(project.getFullPath().append(newPaths[i]), null, null, true); if (!toBeAdded.contains(entry)) toBeAdded.add(index++, entry); } if (toBeAdded.size() == entries.length) return; IClasspathEntry[] updated = (IClasspathEntry[]) toBeAdded .toArray(new IClasspathEntry[toBeAdded.size()]); jproject.setRawClasspath(updated, null); } catch (JavaModelException e) { } }
From source file:com.tasktop.dropwizard.launcher.DropwizardRuntimeClasspathProvider.java
License:Open Source License
protected void addProjectEntries(Set<IRuntimeClasspathEntry> resolved, IPath path, int scope, String classifier, ILaunchConfiguration launchConfiguration, final IProgressMonitor monitor) throws CoreException { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject(path.segment(0)); IMavenProjectFacade projectFacade = projectManager.create(project, monitor); if (projectFacade == null) { return;// w w w . j a v a2s .c om } ResolverConfiguration configuration = projectFacade.getResolverConfiguration(); if (configuration == null) { return; } IJavaProject javaProject = JavaCore.create(project); boolean projectResolved = false; for (IClasspathEntry entry : javaProject.getRawClasspath()) { IRuntimeClasspathEntry rce = null; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: if (!projectResolved) { IMavenClassifierManager mavenClassifierManager = MavenJdtPlugin.getDefault() .getMavenClassifierManager(); IClassifierClasspathProvider classifierClasspathProvider = mavenClassifierManager .getClassifierClasspathProvider(projectFacade, classifier); if (IClasspathManager.CLASSPATH_TEST == scope) { classifierClasspathProvider.setTestClasspath(resolved, projectFacade, monitor); } else { classifierClasspathProvider.setRuntimeClasspath(resolved, projectFacade, monitor); } projectResolved = true; } break; case IClasspathEntry.CPE_CONTAINER: IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), javaProject); if (container != null && !MavenClasspathHelpers.isMaven2ClasspathContainer(entry.getPath())) { switch (container.getKind()) { case IClasspathContainer.K_APPLICATION: rce = JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), IRuntimeClasspathEntry.USER_CLASSES, javaProject); break; default: break; } } break; case IClasspathEntry.CPE_LIBRARY: rce = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()); break; case IClasspathEntry.CPE_VARIABLE: if (!JavaRuntime.JRELIB_VARIABLE.equals(entry.getPath().segment(0))) { rce = JavaRuntime.newVariableRuntimeClasspathEntry(entry.getPath()); } break; case IClasspathEntry.CPE_PROJECT: IProject res = root.getProject(entry.getPath().segment(0)); if (res != null) { IJavaProject otherProject = JavaCore.create(res); if (otherProject != null) { rce = JavaRuntime.newDefaultProjectClasspathEntry(otherProject); } } break; default: break; } if (rce != null) { addStandardClasspathEntries(resolved, rce, launchConfiguration); } } }
From source file:com.threecrickets.creel.eclipse.internal.EclipseUtil.java
License:LGPL
/** * Gets a classpath container from a project. (Assumes that the path is only * used once.)/*from ww w. j a v a 2s .c o m*/ * * @param project * The project * @param path * The path * @return The classpath container or null * @throws JavaModelException * In case of an Eclipse JDT error */ public static IClasspathContainer getClasspathContainer(IJavaProject project, IPath path) throws JavaModelException { IClasspathEntry[] entries = project.getRawClasspath(); for (IClasspathEntry entry : entries) if ((entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) && (entry.getPath().equals(path))) return (IClasspathContainer) entry; return null; }