List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT
int CPE_PROJECT
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT.
Click Source Link
From source file:net.rim.ejde.internal.packaging.PackagingManager.java
License:Open Source License
static private void getCompileImportsRecusively(IClasspathEntry[] entries, IJavaProject jProject, Vector<ImportedJar> imports, boolean isMainProject) throws CoreException { if (imports == null) { imports = new Vector<ImportedJar>(); }//from w ww . j a v a2s . co m // Workspace imports; if there aren't any specified, default to // using the runtime libraries. IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // String jarPathString; try { BlackBerryProperties properties = null; boolean needAddBBJar = false; IPath jarPath = null; ImportedJar importedJar = null; for (IClasspathEntry entry : entries) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: { // libraries IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), jProject.getJavaProject()); if (container == null) { continue; } IVMInstall containerVM; if (!(container instanceof JREContainer)) { // We need to verify the type of the container because the path of Maven container only has one // segment and JavaRuntime.getVMInstall(IPath) return the default VM install if the entry path has one // segment. containerVM = null; } else { containerVM = JavaRuntime.getVMInstall(entry.getPath()); } try { if (containerVM != null) { if (containerVM.getVMInstallType().getId().equals(BlackBerryVMInstallType.VM_ID)) { if (isMainProject) { // Add jars to a list IClasspathEntry[] classpathEntries = container.getClasspathEntries(); if (classpathEntries != null && classpathEntries.length > 0) { getCompileImportsRecusively(classpathEntries, jProject, imports, false); } } } else { if (!jProject.getProject().hasNature(BlackBerryProjectCoreNature.NATURE_ID)) { needAddBBJar = true; continue; } } } else { // Add jars to a list IClasspathEntry[] classpathEntries = container.getClasspathEntries(); if (classpathEntries != null && classpathEntries.length > 0) { getCompileImportsRecusively(classpathEntries, jProject, imports, false); } } } catch (CoreException e) { _log.error(e.getMessage()); continue; } break; } case IClasspathEntry.CPE_LIBRARY: { // imported jars jarPath = PackageUtils.getAbsoluteEntryPath(entry); // the jar path can be null if the jar file does not exist if (jarPath == null) { throw new CoreException(StatusFactory.createErrorStatus( NLS.bind(Messages.PackagingManager_Entry_Not_Found_MSG, entry.getPath()))); } if (jarPath.lastSegment().equals(IConstants.RIM_API_JAR) && needAddBBJar) { needAddBBJar = false; } importedJar = null; if (PackagingUtils.getPackagExportedJar()) { if (entry.isExported()) { if (isMainProject) { // if the exported jar is not in the main project but a dependent project, the classes it // contains are packaged into the dependent project jar. We don't add it to classpath. importedJar = new ImportedJar(jarPath.toOSString(), true, getJarFileType(jarPath.toFile())); } } else { importedJar = new ImportedJar(jarPath.toOSString(), false, getJarFileType(jarPath.toFile())); } } else { importedJar = new ImportedJar(jarPath.toOSString(), false, getJarFileType(jarPath.toFile())); } if (importedJar != null && !existingJar(imports, importedJar)) { imports.add(importedJar); } break; } case IClasspathEntry.CPE_PROJECT: { // dependency projects IProject project = workspaceRoot.getProject(entry.getPath().toString()); IJavaProject javaProject = JavaCore.create(project); try { if (project.hasNature(BlackBerryProjectCoreNature.NATURE_ID)) { properties = ContextManager.PLUGIN.getBBProperties(javaProject.getProject().getName(), false); if (properties == null) { _log.error("BlackBerry properties is null"); break; } } else { properties = BlackBerryPropertiesFactory.createBlackBerryProperties(javaProject); } } catch (CoreException e) { _log.error(e.getMessage()); continue; } if (PackagingManager.getProjectTypeID(properties._application.getType()) == Project.LIBRARY) { IPath absoluteJarPath = PackagingUtils .getAbsoluteStandardOutputFilePath(new BlackBerryProject(javaProject, properties)); File jarFile = new File( absoluteJarPath.toOSString() + IConstants.DOT_MARK + IConstants.JAR_EXTENSION); importedJar = new ImportedJar(jarFile.getAbsolutePath(), false, getJarFileType(jarFile)); if (!existingJar(imports, importedJar)) { imports.add(importedJar); } IClasspathEntry[] subEntries = javaProject.getRawClasspath(); if (subEntries != null && subEntries.length > 0) { getCompileImportsRecusively(subEntries, javaProject, imports, false); } } break; } case IClasspathEntry.CPE_VARIABLE: { // variables String e = entry.getPath().toString(); int index = e.indexOf('/'); if (index == -1) { index = e.indexOf('\\'); } String variable = e; IPath cpvar = JavaCore.getClasspathVariable(variable); if (cpvar == null) { String msg = NLS.bind(Messages.PackagingManager_Variable_Not_Defined_MSG, variable); throw new CoreException(StatusFactory.createErrorStatus(msg)); } if (cpvar.lastSegment().equals(IConstants.RIM_API_JAR) && needAddBBJar) { needAddBBJar = false; } // TODO RAPC does not support a class folder. We may support it later on if (cpvar.lastSegment().endsWith("." + IConstants.JAR_EXTENSION)) { importedJar = new ImportedJar(cpvar.toOSString(), false, getJarFileType(cpvar.toFile())); if (!existingJar(imports, importedJar)) { imports.add(importedJar); } } break; } } } if (needAddBBJar && isMainProject) { // insert the default BB jre lib if needed IVMInstall bbVM = VMUtils.getDefaultBBVM(); if (bbVM != null) { LibraryLocation[] libLocations = bbVM.getLibraryLocations(); if (libLocations != null) { for (LibraryLocation location : libLocations) { importedJar = new ImportedJar(location.getSystemLibraryPath().toOSString(), false, getJarFileType(location.getSystemLibraryPath().toFile())); if (!existingJar(imports, importedJar)) { imports.add(importedJar); } } } } } } catch (JavaModelException e) { _log.error(e.getMessage()); } }
From source file:net.sf.eclipse.tomcat.TomcatBootstrap.java
License:Open Source License
private void getClassPathEntries(IClasspathEntry[] entries, IJavaProject prj, ArrayList data, List selectedPaths, ArrayList visitedProjects, IPath outputPath) { for (IClasspathEntry entrie : entries) { IClasspathEntry entry = entrie;//from w ww .j a v a 2 s .com IPath path = entry.getPath(); if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { path = entry.getOutputLocation(); if (path == null) { continue; } } if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { String prjName = entry.getPath().lastSegment(); if (!visitedProjects.contains(prjName)) { visitedProjects.add(prjName); getClassPathEntries(prj.getJavaModel().getJavaProject(prjName), data, selectedPaths, visitedProjects); } continue; } else if (!selectedPaths.contains(path.toFile().toString().replace('\\', '/'))) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && !entry.getPath().toString().equals("org.eclipse.jdt.launching.JRE_CONTAINER")) { // entires in container are only processed individually // if container itself is not selected IClasspathContainer container; try { container = JavaCore.getClasspathContainer(path, prj); } catch (JavaModelException e1) { TomcatLauncherPlugin.log(e1); container = null; } if (container != null) { getClassPathEntries(container.getClasspathEntries(), prj, data, selectedPaths, visitedProjects, outputPath); } } continue; } IClasspathEntry[] tmpEntry = null; if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { try { tmpEntry = JavaCore.getClasspathContainer(path, prj).getClasspathEntries(); } catch (JavaModelException e1) { TomcatLauncherPlugin.log(e1); continue; } } else { tmpEntry = new IClasspathEntry[1]; tmpEntry[0] = JavaCore.getResolvedClasspathEntry(entry); } for (IClasspathEntry element : tmpEntry) { if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IResource res = prj.getProject().getWorkspace().getRoot().findMember(element.getPath()); if (res != null) { add(data, res); } else { add(data, element.getPath()); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath srcPath = entry.getOutputLocation(); if (srcPath != null && !srcPath.equals(outputPath)) { add(data, prj.getProject().getWorkspace().getRoot().findMember(srcPath)); } } else { TomcatLauncherPlugin.log(">>> " + element); if (element.getPath() != null) { add(data, element.getPath()); } } } } }
From source file:net.sf.eclipse.tomcat.TomcatBootstrap.java
License:Open Source License
private void collectMavenDependencies(IClasspathEntry[] entries, IJavaProject prj, List data, List visitedProjects) {/*from w w w . ja va2s . co m*/ for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; IPath path = entry.getPath(); if ((entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) && entry.getPath().toString().endsWith("MAVEN2_CLASSPATH_CONTAINER")) { IClasspathEntry[] tmpEntry = null; try { tmpEntry = JavaCore.getClasspathContainer(path, prj).getClasspathEntries(); } catch (JavaModelException e1) { TomcatLauncherPlugin.log(e1); continue; } for (int j = 0; j < tmpEntry.length; j++) { if (tmpEntry[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { if (tmpEntry[j].getPath().lastSegment().matches(".*servlet-api[^\\/]{0,10}\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*jasper[^\\/]{0,10}\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*annotations-api[^\\/]{0,10}.\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*el-api[^\\/]{0,10}\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*jsp-api[^\\/]{0,10}\\.jar$")) { continue; } IResource res = prj.getProject().getWorkspace().getRoot().findMember(tmpEntry[j].getPath()); if (res != null) { add(data, res); } else { add(data, tmpEntry[j].getPath()); } } else if (tmpEntry[j].getEntryKind() == IClasspathEntry.CPE_PROJECT) { String prjName = tmpEntry[j].getPath().lastSegment(); IJavaProject subPrj = prj.getJavaModel().getJavaProject(prjName); try { add(data, prj.getProject().getWorkspace().getRoot() .findMember(subPrj.getOutputLocation())); } catch (JavaModelException e1) { TomcatLauncherPlugin.log(e1); continue; } if (!visitedProjects.contains(prjName)) { visitedProjects.add(prjName); collectMavenDependencies(subPrj, data, visitedProjects); } continue; } else { TomcatLauncherPlugin.log(">>> " + tmpEntry[j]); if (tmpEntry[j].getPath() != null) { add(data, tmpEntry[j].getPath()); } } } } } }
From source file:net.sf.eclipse.tomcat.TomcatProjectWebclasspathPropertyPage.java
License:Open Source License
private void getClassPathEntries(IClasspathEntry[] entries, IJavaProject prj, ArrayList data, IPath outputPath) {//from w w w. j a va2 s.c om for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { String prjName = entry.getPath().lastSegment(); if (!visitedProjects.contains(prjName)) { visitedProjects.add(prjName); getClassPathEntries(getJavaProject().getJavaModel().getJavaProject(prjName), data); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { add(data, entry.getPath()); } else if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = entry.getOutputLocation(); if (path != null && !path.equals(outputPath)) { add(data, path); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (!entry.getPath().toString().equals("org.eclipse.jdt.launching.JRE_CONTAINER")) { // Add container itself, as TomcatBootstrap can actually process them // at the moment // Basically, users will be able to choose b/w the whole container // or some artifacts enclosed by it add(data, entry.getPath()); // Expand container and add its content as individual // elements IClasspathContainer container; try { container = JavaCore.getClasspathContainer(entry.getPath(), prj); } catch (JavaModelException e) { TomcatLauncherPlugin.log("failed to obtain classpath container '" + entry.getPath() + "'" + " for project '" + prj.getProject().getName() + "'"); TomcatLauncherPlugin.log(e); container = null; } if (container != null) { getClassPathEntries(container.getClasspathEntries(), prj, data, outputPath); } } } else { add(data, entry.getPath()); } } }
From source file:net.sf.eclipsecs.core.builder.ProjectClassLoader.java
License:Open Source License
/** * Adds the contents of a project to list of URLs. * /*from w w w .j a v a 2 s . co m*/ * @param project the project * @param cpURLs the resulting list * @param isReferenced true if a referenced project is processed */ private static void addToClassPath(IProject project, List<URL> cpURLs, boolean isReferenced, Collection<IProject> processedProjects) { try { // this project has already been added if (processedProjects.contains(project)) { return; } else { processedProjects.add(project); } // get the java project IJavaProject javaProject = JavaCore.create(project); // get the resolved classpath of the project IClasspathEntry[] cpEntries = javaProject.getResolvedClasspath(true); // iterate over classpath to create classpath urls int size = cpEntries.length; for (int i = 0; i < size; i++) { int entryKind = cpEntries[i].getEntryKind(); // handle a source path if (IClasspathEntry.CPE_SOURCE == entryKind) { handleSourcePath(project, cpURLs, cpEntries[i], javaProject); } // handle a project reference else if (IClasspathEntry.CPE_PROJECT == entryKind) { handleRefProject(cpURLs, cpEntries[i], processedProjects); } // handle a library entry else if (IClasspathEntry.CPE_LIBRARY == entryKind) { handleLibrary(project, cpURLs, cpEntries[i]); } // cannot happen since we use a resolved classpath else { // log as exception CheckstylePluginException ex = new CheckstylePluginException( NLS.bind(Messages.errorUnknownClasspathEntry, cpEntries[i].getPath())); CheckstyleLog.log(ex); } } } catch (JavaModelException jme) { CheckstyleLog.log(jme); } }
From source file:net.sf.fjep.fatjar.popup.actions.BuildFatJar.java
License:Open Source License
private void getChildProjects(IJavaProject jproject, Vector projects, boolean exportedOnly) { IClasspathEntry[] cpes = jproject.readRawClasspath(); if (cpes != null) { for (int i = 0; i < cpes.length; i++) { IClasspathEntry cpe = JavaCore.getResolvedClasspathEntry(cpes[i]); if (cpe == null) { System.err.println("Error: cpes[" + i + "]=" + cpes[i] + " does not resolve"); continue; }/*from w w w .ja v a2 s. co m*/ int kind = cpe.getEntryKind(); String name = relPath(cpe.getPath()); if (kind == IClasspathEntry.CPE_CONTAINER) { try { IClasspathContainer container = JavaCore.getClasspathContainer(cpe.getPath(), jproject); if ((container.getKind() == IClasspathContainer.K_APPLICATION) || (container.getKind() == IClasspathContainer.K_SYSTEM)) { IClasspathEntry[] cpes2 = container.getClasspathEntries(); for (int j = 0; j < cpes2.length; j++) { IClasspathEntry cpe2 = cpes2[j]; int kind2 = cpe2.getEntryKind(); String name2 = relPath(cpe2.getPath()); if (name2 == null) { System.err.println("invalid classpath entry: " + cpe2.toString()); } else { if (kind2 == IClasspathEntry.CPE_PROJECT) { if (!exportedOnly || cpe2.isExported()) { if (!projects.contains(name2)) { IJavaProject jChildProject2 = jproject.getJavaModel() .getJavaProject(name2); projects.add(jChildProject2); getChildProjects(jChildProject2, projects, true); } } } } } } } catch (JavaModelException e) { } } else if (kind == IClasspathEntry.CPE_PROJECT) { if (name == null) { System.err.println("invalid classpath entry: " + cpe.toString()); } else { if (!exportedOnly || cpe.isExported()) { if (!projects.contains(name)) { IJavaProject jChildProject = jproject.getJavaModel().getJavaProject(name); projects.add(jChildProject); getChildProjects(jChildProject, projects, true); } } } } } } }
From source file:net.sf.fjep.fatjar.wizards.export.JProjectConfiguration.java
License:Open Source License
/** * Add all jars and class-folders referenced by jproject to jarfiles / * classesDirs. If exportedOnly is true, then only jars/class-folders which * are marked as exported will be added. * /*from w w w . java 2 s . co m*/ * JRE_LIB (.../jre/lib/rt.jar) is ignored and not added to jarfiles * * @param jarfiles * @param classesDirs * @param exportedOnly */ public void addClassPathEntries(Vector jarfiles, Vector classesDirs, Vector projects, boolean exportedOnly) { IClasspathEntry[] cpes = getRawClasspathEntries(); if (cpes != null) { for (int i = 0; i < cpes.length; i++) { IClasspathEntry cpe = JavaCore.getResolvedClasspathEntry(cpes[i]); if ((cpe != null) && (!exportedOnly || cpe.isExported())) { int kind = cpe.getEntryKind(); String dir = relPath(cpe.getPath()); if (kind == IClasspathEntry.CPE_CONTAINER) { try { IClasspathContainer container = JavaCore.getClasspathContainer(cpe.getPath(), jproject); if ((container.getKind() == IClasspathContainer.K_APPLICATION) || (container.getKind() == IClasspathContainer.K_SYSTEM)) { IClasspathEntry[] cpes2 = container.getClasspathEntries(); for (int j = 0; j < cpes2.length; j++) { IClasspathEntry cpe2 = cpes2[j]; int kind2 = cpe2.getEntryKind(); String dir2 = relPath(cpe2.getPath()); String jar2 = getAbsOrProjectPath(dir2); if (jar2 == null) { System.err.println("invalid classpath entry: " + cpe2.toString()); } else { File f2 = new File(jar2); if (f2.isDirectory()) { if (!classesDirs.contains(jar2)) { classesDirs.add(jar2); } } else { // assume jar file if (!jarfiles.contains(jar2)) { jarfiles.add(jar2); } } } } } } catch (JavaModelException e) { } } else if (kind == IClasspathEntry.CPE_LIBRARY) { String jar = getAbsOrProjectPath(dir); if (jar == null) { System.err.println("invalid classpath entry: " + cpe.toString()); } else { // ignore JRE_LIB if (!jar.replace(File.separatorChar, '/').toLowerCase().endsWith("/jre/lib/rt.jar")) { File f = new File(jar); if (f.isDirectory()) { if (!classesDirs.contains(jar)) { classesDirs.add(jar); } } else { // assume jar file if (!jarfiles.contains(jar)) { jarfiles.add(jar); } } } } } else if (kind == IClasspathEntry.CPE_PROJECT) { if (!exportedOnly || cpe.isExported()) { IJavaProject jPro = jproject.getJavaModel().getJavaProject(dir); JProjectConfiguration jProCon = new JProjectConfiguration(jPro, null); if (!projects.contains(jProCon)) { projects.add(jProCon); } } } } } } }
From source file:net.sf.fjep.fatjar.wizards.export.JProjectConfiguration.java
License:Open Source License
public void getChildProjects(Vector projects, boolean exportedOnly) { IClasspathEntry[] cpes = this.getRawClasspathEntries(); if (cpes != null) { for (int i = 0; i < cpes.length; i++) { IClasspathEntry cpe = JavaCore.getResolvedClasspathEntry(cpes[i]); if (cpe == null) { System.err.println("Error: cpes[" + i + "]=" + cpes[i] + " does not resolve"); continue; }//from w ww.ja v a 2 s. c o m int kind = cpe.getEntryKind(); String name = relPath(cpe.getPath()); if (kind == IClasspathEntry.CPE_CONTAINER) { try { IClasspathContainer container = JavaCore.getClasspathContainer(cpe.getPath(), jproject); if ((container.getKind() == IClasspathContainer.K_APPLICATION) || (container.getKind() == IClasspathContainer.K_SYSTEM)) { IClasspathEntry[] cpes2 = container.getClasspathEntries(); for (int j = 0; j < cpes2.length; j++) { IClasspathEntry cpe2 = cpes2[j]; int kind2 = cpe2.getEntryKind(); String name2 = relPath(cpe2.getPath()); if (name2 == null) { System.err.println("invalid classpath entry: " + cpe2.toString()); } else { if (kind2 == IClasspathEntry.CPE_PROJECT) { if (!exportedOnly || cpe2.isExported()) { if (!projects.contains(name2)) { IJavaProject jChildProject2 = jproject.getJavaModel() .getJavaProject(name2); JProjectConfiguration jpcChild2 = new JProjectConfiguration( jChildProject2, null); projects.add(jpcChild2); jpcChild2.getChildProjects(projects, true); } } } } } } } catch (JavaModelException e) { } } else if (kind == IClasspathEntry.CPE_PROJECT) { if (name == null) { System.err.println("invalid classpath entry: " + cpe.toString()); } else { if (!exportedOnly || cpe.isExported()) { if (!projects.contains(name)) { IJavaProject jChildProject = jproject.getJavaModel().getJavaProject(name); JProjectConfiguration jpcChild = new JProjectConfiguration(jChildProject, null); projects.add(jpcChild); jpcChild.getChildProjects(projects, true); } } } } } } }
From source file:net.sf.j2s.core.builder.JavaBuilder.java
License:Open Source License
private IProject[] getRequiredProjects(boolean includeBinaryPrerequisites) { if (this.javaProject == null || this.workspaceRoot == null) return new IProject[0]; ArrayList projects = new ArrayList(); ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager(); try {// w w w . j a v a 2s . c o m IClasspathEntry[] entries = this.javaProject.getExpandedClasspath(); for (int i = 0, l = entries.length; i < l; i++) { IClasspathEntry entry = entries[i]; IPath path = entry.getPath(); IProject p = null; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_PROJECT: p = this.workspaceRoot.getProject(path.lastSegment()); // missing projects are considered too if (((ClasspathEntry) entry).isOptional() && !JavaProject.hasJavaNature(p)) // except if entry is optional p = null; break; case IClasspathEntry.CPE_LIBRARY: if (includeBinaryPrerequisites && path.segmentCount() > 0) { // some binary resources on the class path can come from projects that are not included in the project references IResource resource = this.workspaceRoot.findMember(path.segment(0)); if (resource instanceof IProject) { p = (IProject) resource; } else { resource = externalFoldersManager.getFolder(path); if (resource != null) p = resource.getProject(); } } } if (p != null && !projects.contains(p)) projects.add(p); } } catch (JavaModelException e) { return new IProject[0]; } IProject[] result = new IProject[projects.size()]; projects.toArray(result); return result; }
From source file:net.sf.j2s.core.builder.NameEnvironment.java
License:Open Source License
private void computeClasspathLocations(IWorkspaceRoot root, JavaProject javaProject, SimpleLookupTable binaryLocationsPerProject) throws CoreException { /* Update cycle marker */ IMarker cycleMarker = javaProject.getCycleMarker(); if (cycleMarker != null) { int severity = JavaCore.ERROR.equals(javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true)) ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING; if (severity != cycleMarker.getAttribute(IMarker.SEVERITY, severity)) cycleMarker.setAttribute(IMarker.SEVERITY, severity); }/*from w w w .j a v a 2s. c o m*/ IClasspathEntry[] classpathEntries = javaProject.getExpandedClasspath(); ArrayList sLocations = new ArrayList(classpathEntries.length); ArrayList bLocations = new ArrayList(classpathEntries.length); nextEntry: for (int i = 0, l = classpathEntries.length; i < l; i++) { ClasspathEntry entry = (ClasspathEntry) classpathEntries[i]; IPath path = entry.getPath(); Object target = JavaModel.getTarget(path, true); if (target == null) continue nextEntry; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: if (!(target instanceof IContainer)) continue nextEntry; IPath outputPath = entry.getOutputLocation() != null ? entry.getOutputLocation() : javaProject.getOutputLocation(); IContainer outputFolder; if (outputPath.segmentCount() == 1) { outputFolder = javaProject.getProject(); } else { outputFolder = root.getFolder(outputPath); if (!outputFolder.exists()) createOutputFolder(outputFolder); } sLocations.add(ClasspathLocation.forSourceFolder((IContainer) target, outputFolder, entry.fullInclusionPatternChars(), entry.fullExclusionPatternChars(), entry.ignoreOptionalProblems())); continue nextEntry; case IClasspathEntry.CPE_PROJECT: if (!(target instanceof IProject)) continue nextEntry; IProject prereqProject = (IProject) target; if (!JavaProject.hasJavaNature(prereqProject)) continue nextEntry; // if project doesn't have java nature or is not accessible JavaProject prereqJavaProject = (JavaProject) JavaCore.create(prereqProject); IClasspathEntry[] prereqClasspathEntries = prereqJavaProject.getRawClasspath(); ArrayList seen = new ArrayList(); nextPrereqEntry: for (int j = 0, m = prereqClasspathEntries.length; j < m; j++) { IClasspathEntry prereqEntry = prereqClasspathEntries[j]; if (prereqEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { Object prereqTarget = JavaModel.getTarget(prereqEntry.getPath(), true); if (!(prereqTarget instanceof IContainer)) continue nextPrereqEntry; IPath prereqOutputPath = prereqEntry.getOutputLocation() != null ? prereqEntry.getOutputLocation() : prereqJavaProject.getOutputLocation(); IContainer binaryFolder = prereqOutputPath.segmentCount() == 1 ? (IContainer) prereqProject : (IContainer) root.getFolder(prereqOutputPath); if (binaryFolder.exists() && !seen.contains(binaryFolder)) { seen.add(binaryFolder); ClasspathLocation bLocation = ClasspathLocation.forBinaryFolder(binaryFolder, true, entry.getAccessRuleSet()); bLocations.add(bLocation); if (binaryLocationsPerProject != null) { // normal builder mode ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject .get(prereqProject); if (existingLocations == null) { existingLocations = new ClasspathLocation[] { bLocation }; } else { int size = existingLocations.length; System.arraycopy(existingLocations, 0, existingLocations = new ClasspathLocation[size + 1], 0, size); existingLocations[size] = bLocation; } binaryLocationsPerProject.put(prereqProject, existingLocations); } } } } continue nextEntry; case IClasspathEntry.CPE_LIBRARY: if (target instanceof IResource) { IResource resource = (IResource) target; ClasspathLocation bLocation = null; if (resource instanceof IFile) { AccessRuleSet accessRuleSet = (JavaCore.IGNORE .equals(javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) && JavaCore.IGNORE.equals( javaProject.getOption(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, true))) ? null : entry.getAccessRuleSet(); bLocation = ClasspathLocation.forLibrary((IFile) resource, accessRuleSet); } else if (resource instanceof IContainer) { AccessRuleSet accessRuleSet = (JavaCore.IGNORE .equals(javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) && JavaCore.IGNORE.equals( javaProject.getOption(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, true))) ? null : entry.getAccessRuleSet(); bLocation = ClasspathLocation.forBinaryFolder((IContainer) target, false, accessRuleSet); // is library folder not output folder } bLocations.add(bLocation); if (binaryLocationsPerProject != null) { // normal builder mode IProject p = resource.getProject(); // can be the project being built ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject .get(p); if (existingLocations == null) { existingLocations = new ClasspathLocation[] { bLocation }; } else { int size = existingLocations.length; System.arraycopy(existingLocations, 0, existingLocations = new ClasspathLocation[size + 1], 0, size); existingLocations[size] = bLocation; } binaryLocationsPerProject.put(p, existingLocations); } } else if (target instanceof File) { AccessRuleSet accessRuleSet = (JavaCore.IGNORE .equals(javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) && JavaCore.IGNORE.equals( javaProject.getOption(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, true))) ? null : entry.getAccessRuleSet(); bLocations.add(ClasspathLocation.forLibrary(path.toString(), accessRuleSet)); } continue nextEntry; } } // now split the classpath locations... place the output folders ahead of the other .class file folders & jars ArrayList outputFolders = new ArrayList(1); this.sourceLocations = new ClasspathMultiDirectory[sLocations.size()]; if (!sLocations.isEmpty()) { sLocations.toArray(this.sourceLocations); // collect the output folders, skipping duplicates next: for (int i = 0, l = this.sourceLocations.length; i < l; i++) { ClasspathMultiDirectory md = this.sourceLocations[i]; IPath outputPath = md.binaryFolder.getFullPath(); for (int j = 0; j < i; j++) { // compare against previously walked source folders if (outputPath.equals(this.sourceLocations[j].binaryFolder.getFullPath())) { md.hasIndependentOutputFolder = this.sourceLocations[j].hasIndependentOutputFolder; continue next; } } outputFolders.add(md); // also tag each source folder whose output folder is an independent folder & is not also a source folder for (int j = 0, m = this.sourceLocations.length; j < m; j++) if (outputPath.equals(this.sourceLocations[j].sourceFolder.getFullPath())) continue next; md.hasIndependentOutputFolder = true; } } // combine the output folders with the binary folders & jars... place the output folders before other .class file folders & jars this.binaryLocations = new ClasspathLocation[outputFolders.size() + bLocations.size()]; int index = 0; for (int i = 0, l = outputFolders.size(); i < l; i++) this.binaryLocations[index++] = (ClasspathLocation) outputFolders.get(i); for (int i = 0, l = bLocations.size(); i < l; i++) this.binaryLocations[index++] = (ClasspathLocation) bLocations.get(i); }