Example usage for org.eclipse.jdt.core IJavaProject setRawClasspath

List of usage examples for org.eclipse.jdt.core IJavaProject setRawClasspath

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaProject setRawClasspath.

Prototype

void setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor) throws JavaModelException;

Source Link

Document

Sets the classpath of this project using a list of classpath entries.

Usage

From source file:org.eclim.plugin.jdt.project.JavaProjectManager.java

License:Open Source License

/**
 * Sets the classpath for the supplied project.
 *
 * @param javaProject The project.//from  w ww .j  a v a2s.  c o  m
 * @param entries The classpath entries.
 * @param classpath The file path of the .classpath file.
 * @return Array of Error or null if no errors reported.
 */
protected List<Error> setClasspath(IJavaProject javaProject, IClasspathEntry[] entries, String classpath)
        throws Exception {
    FileOffsets offsets = FileOffsets.compile(classpath);
    String classpathValue = IOUtils.toString(new FileInputStream(classpath));
    ArrayList<Error> errors = new ArrayList<Error>();
    for (IClasspathEntry entry : entries) {
        IJavaModelStatus status = JavaConventions.validateClasspathEntry(javaProject, entry, true);
        if (!status.isOK()) {
            errors.add(createErrorForEntry(javaProject, entry, status, offsets, classpath, classpathValue));
        }
    }

    IJavaModelStatus status = JavaConventions.validateClasspath(javaProject, entries,
            javaProject.getOutputLocation());

    // always set the classpathValue anyways, so that the user can correct the
    // file.
    //if(status.isOK() && errors.isEmpty()){
    javaProject.setRawClasspath(entries, null);
    javaProject.makeConsistent(null);
    //}

    if (!status.isOK()) {
        errors.add(new Error(status.getMessage(), classpath, 1, 1, false));
    }
    return errors;
}

From source file:org.eclipse.acceleo.internal.ide.ui.wizards.project.AcceleoProjectWizard.java

License:Open Source License

/**
 * Convert the empty project to an Acceleo project.
 * // w  ww  .j  av  a  2  s.c  o m
 * @param project
 *            The newly created project.
 * @param selectedJVM
 *            The name of the selected JVM (J2SE-1.5 or JavaSE-1.6 recommended).
 * @param allModules
 *            The description of the module that need to be created.
 * @param shouldGenerateModules
 *            Indicates if we should generate the modules in the project or not. The wizard container to
 *            display the progress monitor
 * @param monitor
 *            The monitor.
 */
public static void convert(IProject project, String selectedJVM, List<AcceleoModule> allModules,
        boolean shouldGenerateModules, IProgressMonitor monitor) {
    String generatorName = computeGeneratorName(project.getName());
    AcceleoProject acceleoProject = AcceleowizardmodelFactory.eINSTANCE.createAcceleoProject();
    acceleoProject.setName(project.getName());
    acceleoProject.setGeneratorName(generatorName);

    // Default JRE value
    acceleoProject.setJre(selectedJVM);
    if (acceleoProject.getJre() == null || acceleoProject.getJre().length() == 0) {
        acceleoProject.setJre("J2SE-1.5"); //$NON-NLS-1$         
    }

    if (shouldGenerateModules) {
        for (AcceleoModule acceleoModule : allModules) {
            String parentFolder = acceleoModule.getParentFolder();
            IProject moduleProject = ResourcesPlugin.getWorkspace().getRoot()
                    .getProject(acceleoModule.getProjectName());
            if (moduleProject.exists() && moduleProject.isAccessible()
                    && acceleoModule.getModuleElement() != null
                    && acceleoModule.getModuleElement().isIsMain()) {
                IPath parentFolderPath = new Path(parentFolder);
                IFolder folder = moduleProject.getFolder(parentFolderPath.removeFirstSegments(1));
                acceleoProject.getExportedPackages()
                        .add(folder.getProjectRelativePath().removeFirstSegments(1).toString().replaceAll("/", //$NON-NLS-1$
                                "\\.")); //$NON-NLS-1$
            }
            // Calculate project dependencies
            List<String> metamodelURIs = acceleoModule.getMetamodelURIs();
            for (String metamodelURI : metamodelURIs) {
                // Find the project containing this metamodel and add a dependency to it.
                EPackage ePackage = AcceleoPackageRegistry.INSTANCE.getEPackage(metamodelURI);
                if (ePackage != null && !(ePackage instanceof EcorePackage)) {
                    Bundle bundle = AcceleoWorkspaceUtil.getBundle(ePackage.getClass());
                    acceleoProject.getPluginDependencies().add(bundle.getSymbolicName());
                }
            }
        }
    }

    try {
        IProjectDescription description = project.getDescription();
        description.setNatureIds(new String[] { JavaCore.NATURE_ID, IBundleProjectDescription.PLUGIN_NATURE,
                IAcceleoConstants.ACCELEO_NATURE_ID, });
        project.setDescription(description, monitor);

        IJavaProject iJavaProject = JavaCore.create(project);

        // Compute the JRE
        List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
        IExecutionEnvironmentsManager executionEnvironmentsManager = JavaRuntime
                .getExecutionEnvironmentsManager();
        IExecutionEnvironment[] executionEnvironments = executionEnvironmentsManager.getExecutionEnvironments();
        for (IExecutionEnvironment iExecutionEnvironment : executionEnvironments) {
            if (acceleoProject.getJre().equals(iExecutionEnvironment.getId())) {
                entries.add(JavaCore.newContainerEntry(JavaRuntime.newJREContainerPath(iExecutionEnvironment)));
                break;
            }
        }

        // PDE Entry (will not be generated anymore)
        entries.add(JavaCore.newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins"))); //$NON-NLS-1$

        // Sets the input / output folders
        IFolder target = project.getFolder("src"); //$NON-NLS-1$
        if (!target.exists()) {
            target.create(true, true, monitor);
        }

        IFolder classes = project.getFolder("bin"); //$NON-NLS-1$
        if (!classes.exists()) {
            classes.create(true, true, monitor);
        }

        iJavaProject.setOutputLocation(classes.getFullPath(), monitor);
        IPackageFragmentRoot packageRoot = iJavaProject.getPackageFragmentRoot(target);
        entries.add(JavaCore.newSourceEntry(packageRoot.getPath(), new Path[] {}, new Path[] {},
                classes.getFullPath()));

        iJavaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
        iJavaProject.open(monitor);

        AcceleoProjectUtils.generateFiles(acceleoProject, allModules, project, shouldGenerateModules, monitor);

        // Default settings
        AcceleoBuilderSettings settings = new AcceleoBuilderSettings(project);
        settings.setCompilationKind(AcceleoBuilderSettings.COMPILATION_PLATFORM_RESOURCE);
        settings.setResourceKind(AcceleoBuilderSettings.BUILD_XMI_RESOURCE);
        settings.save();
    } catch (CoreException e) {
        AcceleoUIActivator.log(e, true);
    }
}

From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java

License:Open Source License

/**
 * Firstly, add library to the Java build path if it's not there already,
 * then mark the entry as being on the aspect path
 * @param project//from  w  ww  .  ja  v a2 s.c  om
 * @param path
 */
private static void addAttribute(IProject project, String jarPath, int eKind, IClasspathAttribute attribute) {
    IJavaProject jp = JavaCore.create(project);

    try {
        IClasspathEntry[] cp = jp.getRawClasspath();
        int cpIndex = getIndexInBuildPathEntry(cp, jarPath);
        if (cpIndex >= 0) { // already on classpath
            // add attribute to classpath entry
            // if it doesn't already exist
            IClasspathEntry pathAdd = cp[cpIndex];
            // only add attribute if this element is not already on the path
            if (isAspectPathAttribute(attribute) ? !isOnAspectpath(pathAdd) : !isOnInpath(pathAdd)) {
                IClasspathAttribute[] attributes = pathAdd.getExtraAttributes();
                IClasspathAttribute[] newattrib = new IClasspathAttribute[attributes.length + 1];
                System.arraycopy(attributes, 0, newattrib, 0, attributes.length);
                newattrib[attributes.length] = attribute;
                switch (pathAdd.getEntryKind()) {
                case IClasspathEntry.CPE_LIBRARY:
                    pathAdd = JavaCore.newLibraryEntry(pathAdd.getPath(), pathAdd.getSourceAttachmentPath(),
                            pathAdd.getSourceAttachmentRootPath(), pathAdd.getAccessRules(), newattrib,
                            pathAdd.isExported());
                    break;

                case IClasspathEntry.CPE_VARIABLE:
                    pathAdd = JavaCore.newVariableEntry(pathAdd.getPath(), pathAdd.getSourceAttachmentPath(),
                            pathAdd.getSourceAttachmentRootPath(), pathAdd.getAccessRules(), newattrib,
                            pathAdd.isExported());
                    break;

                case IClasspathEntry.CPE_CONTAINER:
                    pathAdd = JavaCore.newContainerEntry(pathAdd.getPath(), pathAdd.getAccessRules(), newattrib,
                            pathAdd.isExported());
                    break;

                case IClasspathEntry.CPE_PROJECT:
                    pathAdd = JavaCore.newProjectEntry(pathAdd.getPath(), pathAdd.getAccessRules(), true,
                            newattrib, pathAdd.isExported());
                    break;
                }

                cp[cpIndex] = pathAdd;
                jp.setRawClasspath(cp, null);
            }
        } else {
            addEntryToJavaBuildPath(jp, attribute, jarPath, eKind);
        }
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java

License:Open Source License

private static void addAttribute(IJavaProject jp, IClasspathEntry entry, IClasspathAttribute attr) {
    try {/*from ww w.j  a va 2 s  .c  o  m*/
        IClasspathEntry[] cp = jp.getRawClasspath();
        for (int i = 0; i < cp.length; i++) {
            if (cp[i].equals(entry)) {
                IClasspathAttribute[] attributes = cp[i].getExtraAttributes();
                IClasspathAttribute[] newattrib = new IClasspathAttribute[attributes.length + 1];
                System.arraycopy(attributes, 0, newattrib, 0, attributes.length);
                newattrib[attributes.length] = attr;
                switch (cp[i].getEntryKind()) {
                case IClasspathEntry.CPE_LIBRARY:
                    cp[i] = JavaCore.newLibraryEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(),
                            cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_VARIABLE:
                    cp[i] = JavaCore.newVariableEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(),
                            cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_CONTAINER:
                    cp[i] = JavaCore.newContainerEntry(cp[i].getPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_PROJECT:
                    cp[i] = JavaCore.newProjectEntry(cp[i].getPath(), cp[i].getAccessRules(), true, newattrib,
                            cp[i].isExported());
                    break;

                }
            }
        }
        jp.setRawClasspath(cp, null);
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java

License:Open Source License

public static void removeAttribute(IJavaProject jp, IClasspathEntry entry, IClasspathAttribute attr) {
    try {//from  w ww.j a v  a 2s  . c o m
        IClasspathEntry[] cp = jp.getRawClasspath();
        for (int i = 0; i < cp.length; i++) {
            if (cp[i].equals(entry)) {
                IClasspathAttribute[] attributes = cp[i].getExtraAttributes();
                IClasspathAttribute[] newattrib = new IClasspathAttribute[attributes.length - 1];
                int count = 0;
                for (int j = 0; j < attributes.length; j++) {
                    if (!attributes[j].getName().equals(attr.getName())) {
                        newattrib[count++] = attributes[j];
                    }
                }
                switch (cp[i].getEntryKind()) {
                case IClasspathEntry.CPE_LIBRARY:
                    cp[i] = JavaCore.newLibraryEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(),
                            cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_VARIABLE:
                    cp[i] = JavaCore.newVariableEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(),
                            cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_CONTAINER:
                    cp[i] = JavaCore.newContainerEntry(cp[i].getPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_PROJECT:
                    cp[i] = JavaCore.newProjectEntry(cp[i].getPath(), cp[i].getAccessRules(), true, newattrib,
                            cp[i].isExported());
                    break;
                }
            }
        }
        jp.setRawClasspath(cp, null);
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java

License:Open Source License

/**
* Remove all occurrences of an attribute
* @param javaProject//from  w  ww. j a  va2  s .c om
* @param attribute
*/
private static void removeAttribute(IJavaProject javaProject, IClasspathAttribute attribute) {
    try {
        IClasspathEntry[] cp = javaProject.getRawClasspath();
        boolean changed = false;
        for (int i = 0; i < cp.length; i++) {
            IClasspathAttribute[] attributes = cp[i].getExtraAttributes();
            boolean found = false;
            for (int j = 0; !found && (j < attributes.length); j++) {
                if (attributes[j].getName().equals(attribute.getName())) {
                    found = true;
                }
            }
            if (found) {
                changed = true;
                IClasspathAttribute[] newattrib = new IClasspathAttribute[attributes.length - 1];
                int count = 0;
                for (int j = 0; j < attributes.length; j++) {
                    if (!attributes[j].getName().equals(attribute.getName())) {
                        newattrib[count++] = attributes[j];
                    }
                }
                switch (cp[i].getEntryKind()) {
                case IClasspathEntry.CPE_LIBRARY:
                    cp[i] = JavaCore.newLibraryEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(),
                            cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_VARIABLE:
                    cp[i] = JavaCore.newVariableEntry(cp[i].getPath(), cp[i].getSourceAttachmentPath(),
                            cp[i].getSourceAttachmentRootPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_CONTAINER:
                    cp[i] = JavaCore.newContainerEntry(cp[i].getPath(), cp[i].getAccessRules(), newattrib,
                            cp[i].isExported());
                    break;

                case IClasspathEntry.CPE_PROJECT:
                    cp[i] = JavaCore.newProjectEntry(cp[i].getPath(), cp[i].getAccessRules(), true, newattrib,
                            cp[i].isExported());
                    break;
                }
            }
        }
        if (changed) {
            javaProject.setRawClasspath(cp, null);
        }
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java

License:Open Source License

private static void addEntryToJavaBuildPath(IJavaProject jp, IClasspathAttribute attribute, String path,
        int eKind) {
    IClasspathAttribute[] attributes = new IClasspathAttribute[] { attribute };
    try {//from  ww  w . j  ava  2 s  .c om
        IClasspathEntry[] originalCP = jp.getRawClasspath();
        IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length + 1];
        IClasspathEntry cp = null;
        if (eKind == IClasspathEntry.CPE_LIBRARY) {
            cp = JavaCore.newLibraryEntry(new Path(path), null, null, new IAccessRule[0], attributes, false);
        } else if (eKind == IClasspathEntry.CPE_VARIABLE) {
            cp = JavaCore.newVariableEntry(new Path(path), null, null, new IAccessRule[0], attributes, false);
        } else if (eKind == IClasspathEntry.CPE_CONTAINER) {
            cp = JavaCore.newContainerEntry(new Path(path), null, attributes, false);
        } else if (eKind == IClasspathEntry.CPE_PROJECT) {
            cp = JavaCore.newProjectEntry(new Path(path), null, true, attributes, false);
        }

        // Update the raw classpath with the new entry.
        if (cp != null) {
            System.arraycopy(originalCP, 0, newCP, 0, originalCP.length);
            newCP[originalCP.length] = cp;
            jp.setRawClasspath(newCP, new NullProgressMonitor());
        }
    } catch (JavaModelException e) {
    } catch (NumberFormatException e) {
    }
}

From source file:org.eclipse.ajdt.core.AspectJCorePreferences.java

License:Open Source License

/**
 * If this classpath entry's path already exists on the classpath, then it is replaced
 * else it is added//from www .j a  v a2 s.  co  m
 */
public static void updateClasspathEntry(IProject project, IClasspathEntry newEntry) {
    IJavaProject jProject = JavaCore.create(project);
    try {
        IClasspathEntry[] entries = jProject.getRawClasspath();
        for (int i = 0; i < entries.length; i++) {
            IClasspathEntry entry = entries[i];
            if (newEntry.getPath().equals(entry.getPath())) {
                entries[i] = newEntry;
                jProject.setRawClasspath(entries, null);
                return;
            }
        }

        // entry not found on classpath...add it
        IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
        System.arraycopy(entries, 0, newEntries, 0, entries.length);
        newEntries[entries.length] = newEntry;
        jProject.setRawClasspath(newEntries, null);
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.core.builder.AJBuilder.java

License:Open Source License

private void migrateToRTContainerIfNecessary(IJavaProject javaProject) {
    if (!AspectJRTInitializer.hasBeenUsed) {
        // if the old ASPECTJRT_LIB var hasn't been initialized
        // then there definitely won't be anything to migrate
        return;/*from  ww w  .  j  a v a 2 s.  c om*/
    }
    try {
        IClasspathEntry[] entries = javaProject.getRawClasspath();
        for (int i = 0; i < entries.length; i++) {
            if (entries[i].getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
                String var = entries[i].getPath().segment(0);
                if (var.equals("ASPECTJRT_LIB")) { //$NON-NLS-1$
                    // replace with AspectJRT container
                    entries[i] = JavaCore.newContainerEntry(new Path(AspectJPlugin.ASPECTJRT_CONTAINER), false);
                    javaProject.setRawClasspath(entries, new NullProgressMonitor());
                    return;
                }
            }
        }
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.core.buildpath.BuildConfigurationUtils.java

License:Open Source License

public static void applyBuildConfiguration(IFile ifile) {
    File file = ifile.getLocation().toFile();
    BufferedReader br = null;/*from w w w.  java  2  s.  c o  m*/
    try {
        IJavaProject project = JavaCore.create(ifile.getProject());
        List classpathEntries = new ArrayList();
        IClasspathEntry[] originalEntries = project.getRawClasspath();
        for (int i = 0; i < originalEntries.length; i++) {
            IClasspathEntry entry = originalEntries[i];
            if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) {
                classpathEntries.add(entry);
            }
        }
        List srcFolders = new ArrayList();
        Map srcFoldersToIncludes = new HashMap();
        Map srcFoldersToExcludes = new HashMap();
        br = new BufferedReader(new FileReader(file));
        Properties properties = new Properties();
        properties.load(ifile.getContents());
        Enumeration iter = properties.keys();

        // first stage - find any source folders
        while (iter.hasMoreElements()) {
            String name = iter.nextElement().toString();
            String value = properties.get(name).toString();
            String[] values = value.split(","); //$NON-NLS-1$
            if (name.equals("src.includes")) { //$NON-NLS-1$
                for (int i = 0; i < values.length; i++) {
                    String inc = values[i];
                    if (inc.equals("/")) { //$NON-NLS-1$
                        srcFolders.add(inc);
                    } else if (inc.indexOf("/") == inc.length() - 1) { //$NON-NLS-1$
                        if (project.getProject().getFolder(inc) != null
                                && project.getProject().getFolder(inc).exists()) {
                            srcFolders.add(inc);
                        }
                    }
                }
            }
        }

        // second stage - identify include and exclude filters
        iter = properties.keys();
        if (srcFolders.isEmpty()) {
            srcFolders.add(""); //$NON-NLS-1$
        }
        while (iter.hasMoreElements()) {
            String name = iter.nextElement().toString();
            String value = properties.get(name).toString();
            String[] values = value.split(","); //$NON-NLS-1$
            if (name.equals("src.inclusionpatterns")) { //$NON-NLS-1$
                for (int i = 0; i < values.length; i++) {
                    String inc = values[i];
                    for (Iterator iterator = srcFolders.iterator(); iterator.hasNext();) {
                        String srcFolder = (String) iterator.next();
                        if (inc.startsWith(srcFolder)) {
                            List incs = (List) srcFoldersToIncludes.get(srcFolder);
                            if (incs == null) {
                                incs = new ArrayList();
                            }
                            incs.add(inc);
                            srcFoldersToIncludes.put(srcFolder, incs);
                        }
                    }
                }
            } else if (name.equals("src.excludes")) { //$NON-NLS-1$
                for (int i = 0; i < values.length; i++) {
                    String exc = values[i];
                    for (Iterator iterator = srcFolders.iterator(); iterator.hasNext();) {
                        String srcFolder = (String) iterator.next();
                        if (srcFolder.equals("/") || exc.startsWith(srcFolder)) { //$NON-NLS-1$
                            List excs = (List) srcFoldersToExcludes.get(srcFolder);
                            if (excs == null) {
                                excs = new ArrayList();
                            }
                            excs.add(exc);
                            srcFoldersToExcludes.put(srcFolder, excs);
                        }
                    }
                }
            }
        }

        // third stage - create classpath entries
        IClasspathEntry[] entries = new IClasspathEntry[srcFolders.size() + classpathEntries.size()];
        for (int i = 0; i < entries.length; i++) {
            if (srcFolders.size() > i) {
                String srcFolder = (String) srcFolders.get(i);
                IPath path = project.getPath().append(stripSlash(srcFolder));
                List exclusions = (List) srcFoldersToExcludes.get(srcFolder);
                if (exclusions == null) {
                    exclusions = Collections.EMPTY_LIST;
                }
                List inclusions = (List) srcFoldersToIncludes.get(srcFolder);
                if (inclusions == null) {
                    inclusions = Collections.EMPTY_LIST;
                }
                IPath[] exclusionPatterns = new IPath[exclusions.size()];
                for (int j = 0; j < exclusionPatterns.length; j++) {
                    String exclusionPathStr = (String) exclusions.get(j);
                    if (exclusionPathStr.startsWith(srcFolder)) {
                        exclusionPathStr = exclusionPathStr.substring(srcFolder.length());
                    }
                    IPath exclusionPath = new Path(exclusionPathStr);
                    exclusionPatterns[j] = exclusionPath;

                }
                IPath[] inclusionPatterns = new IPath[inclusions.size()];
                for (int j = 0; j < inclusionPatterns.length; j++) {
                    String inclusionPathStr = (String) inclusions.get(j);
                    if (inclusionPathStr.startsWith(srcFolder)) {
                        inclusionPathStr = inclusionPathStr.substring(srcFolder.length());
                    }
                    IPath inclusionPath = new Path(inclusionPathStr);
                    inclusionPatterns[j] = inclusionPath;

                }
                IClasspathEntry classpathEntry = JavaCore.newSourceEntry(path, exclusionPatterns);
                //new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, path, ClasspathEntry.INCLUDE_ALL, exclusionPatterns, null, null, null, true, ClasspathEntry.NO_ACCESS_RULES, false, ClasspathEntry.NO_EXTRA_ATTRIBUTES);
                entries[i] = classpathEntry;
            } else {
                entries[i] = (IClasspathEntry) classpathEntries.get(i - srcFolders.size());
            }
        }
        project.setRawClasspath(entries, null);
    } catch (FileNotFoundException e) {
    } catch (JavaModelException e) {
    } catch (IOException e) {
    } catch (CoreException e) {
    } finally {
        if (br != null) {
            try {
                br.close();
            } catch (IOException e) {
            }
        }
    }
}