Example usage for org.eclipse.jdt.core IClasspathEntry getPath

List of usage examples for org.eclipse.jdt.core IClasspathEntry getPath

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IClasspathEntry getPath.

Prototype

IPath getPath();

Source Link

Document

Returns the path of this classpath entry.

Usage

From source file:net.sf.eclipsecs.core.builder.ProjectClassLoader.java

License:Open Source License

/**
 * Helper method to handle a source path.
 * //from www  .  j  a  va 2  s  .  c o  m
 * @param project the original project
 * @param cpURLs the list that is to contain the projects classpath
 * @param entry the actually processed classpath entry
 * @param javapProject the java project
 * @throws JavaModelException an exception with the java project occured
 */
private static void handleSourcePath(IProject project, List<URL> cpURLs, IClasspathEntry entry,
        IJavaProject javapProject) throws JavaModelException {

    IPath sourcePath = entry.getPath();

    // check for if the output path is different to the source path
    IPath outputPath = entry.getOutputLocation();

    if (outputPath == null) {
        sourcePath = javapProject.getOutputLocation();
    } else if (!outputPath.equals(sourcePath)) {

        // make the output path the relevant path since it contains the
        // class files
        sourcePath = outputPath;
    }

    // check if the sourcepath is relative to the project
    IPath projPath = project.getFullPath();

    if (!projPath.equals(sourcePath) && sourcePath.matchingFirstSegments(projPath) > 0) {

        // remove the project part from the source path
        sourcePath = sourcePath.removeFirstSegments(projPath.segmentCount());

        // get the folder for the path
        IFolder sourceFolder = project.getFolder(sourcePath);

        // get the absolute path for the folder
        sourcePath = sourceFolder.getLocation();
    } else if (projPath.equals(sourcePath)) {
        sourcePath = project.getLocation();
    }

    // try to add the path to the classpath
    handlePath(sourcePath, cpURLs);
}

From source file:net.sf.eclipsecs.core.builder.ProjectClassLoader.java

License:Open Source License

/**
 * Helper method to handle a referenced project for the classpath.
 * /*from  w  ww . j  a va  2  s .  c om*/
 * @param cpURLs the list that is to contain the projects classpath
 * @param entry the actually processed classpath entry
 */
private static void handleRefProject(List<URL> cpURLs, IClasspathEntry entry,
        Collection<IProject> processedProjects) {

    // get the referenced project from the workspace
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject referencedProject = root.getProject(entry.getPath().toString());

    // add the referenced projects contents
    if (referencedProject.exists()) {
        addToClassPath(referencedProject, cpURLs, true, processedProjects);
    }
}

From source file:net.sf.eclipsecs.core.builder.ProjectClassLoader.java

License:Open Source License

/**
 * Helper method to handle a library for the classpath.
 * /*from  w  w  w . j  a va 2s  . c  om*/
 * @param project the original project
 * @param cpURLs the list that is to contain the projects classpath
 * @param entry the actually processed classpath entry
 */
private static void handleLibrary(IProject project, List<URL> cpURLs, IClasspathEntry entry) {

    IPath libPath = entry.getPath();

    // check if the library path is relative to the project
    // can happen if the library is contained within the project
    IPath projPath = project.getFullPath();
    if (libPath.matchingFirstSegments(projPath) > 0) {

        // remove the project part from the source path
        libPath = libPath.removeFirstSegments(projPath.segmentCount());

        // fixes 1422937 - Thanks to Peter Hendriks
        if (!libPath.isEmpty()) { // added check

            // get the file handle for the library
            IFile file = project.getFile(libPath);

            // get the absolute path for the library file
            libPath = file.getLocation();

        } else {
            // fallback to project root when libPath is empty
            libPath = project.getLocation();
        }
    } else {
        // Check if the resource is otherwise relative to the workspace
        IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(libPath);
        if (resource != null && resource.exists()) {
            libPath = resource.getLocation();
        }
    }

    // try to add the path to the classpath
    handlePath(libPath, cpURLs);
}

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  ww . j a v  a  2 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.popup.actions.BuildFatJar.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 ww .  j a  v a2  s . c o m*/
 * JRE_LIB (.../jre/lib/rt.jar) is ignored and not added to jarfiles
 * 
 * @param jproject
 * @param jarfiles
 * @param classesDirs
 * @param exportedOnly
 */
private void getClassPathJars(IJavaProject jproject, Vector jarfiles, Vector classesDirs,
        boolean exportedOnly) {

    IProject project = jproject.getProject();
    IWorkspace workspace = project.getWorkspace();
    IWorkspaceRoot workspaceRoot = workspace.getRoot();
    String rootDir = absPath(workspaceRoot.getLocation());
    IClasspathEntry[] cpes = jproject.readRawClasspath();
    // cpes = jproject.getResolvedClasspath(true);
    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 = absOrProjectPath(workspaceRoot, 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 = absOrProjectPath(workspaceRoot, 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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

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 ww .  j  av  a2 s  . c o 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

/**
 * 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.
 * /*  w  w w  .  ja va2  s . co m*/
 * JRE_LIB (.../jre/lib/rt.jar) is ignored and not added to jarfiles
 * 
 * @param jarfiles
 * @param classesDirs
 * @param exportedOnly
 */
public void getClassPathJars(Vector jarfiles, Vector classesDirs, 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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

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  w w .ja  v  a 2  s  .c om
            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 {//from w w  w .  j a  va2  s  .co  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);
    }/*w w w .  jav  a2s.c  om*/

    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);
}