List of usage examples for org.eclipse.jdt.core IJavaProject setRawClasspath
void setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor) throws JavaModelException;
From source file:me.gladwell.eclipse.m2e.android.configuration.classpath.ReorderClasspathConfigurer.java
License:Open Source License
public void configure(MavenAndroidProject mavenProject, IDEAndroidProject eclipseProject, IClasspathDescriptor classpath) { try {/*from ww w.j a v a2 s . co m*/ IJavaProject javaproject = JavaCore.create(eclipseProject.getProject()); IClasspathEntry[] tosort = javaproject.readRawClasspath(); sort(tosort, bySourceFolderOrdering(mavenProject)); javaproject.setRawClasspath(tosort, new NullProgressMonitor()); javaproject.save(new NullProgressMonitor(), false); } catch (JavaModelException e) { throw new ProjectConfigurationException("error re-ordering classpath", e); } }
From source file:me.gladwell.eclipse.m2e.android.configuration.workspace.MarkAndroidClasspathContainerNotExportedConfigurer.java
License:Open Source License
public void configure(IDEAndroidProject eclipseProject, MavenAndroidProject mavenProject) { try {// w ww . java2 s. c o m IJavaProject javaProject = JavaCore.create(eclipseProject.getProject()); IClasspathDescriptor classpath = new ClasspathDescriptor(javaProject); IDEAndroidProject androidProject = factory.createAndroidProject(javaProject.getProject(), classpath); androidProject.getClasspath().getAndroidClasspathContainer().markNotExported(); List<IClasspathEntryDescriptor> descriptors = classpath.getEntryDescriptors(); IClasspathEntry[] entries = new IClasspathEntry[descriptors.size()]; for (int i = 0; i < descriptors.size(); ++i) { entries[i] = descriptors.get(i).toClasspathEntry(); } javaProject.setRawClasspath(entries, new NullProgressMonitor()); } catch (JavaModelException e) { throw new ProjectConfigurationException("Could not mark ADT libraries container as not exported", e); } }
From source file:monolipse.core.internal.BooNature.java
License:Open Source License
private void addExclusionPatternsToSourceFoldersOf(IJavaProject javaProject) throws JavaModelException { IClasspathEntry[] classpath = javaProject.getRawClasspath(); Map<IClasspathEntry, IClasspathEntry> modified = addExclusionPatternsTo(classpath); if (modified.isEmpty()) return;// ww w. j a v a 2s.c o m javaProject.setRawClasspath(replaceModifiedClasspathEntries(classpath, modified), null); }
From source file:net.rim.ejde.internal.util.ImportUtils.java
License:Open Source License
/** * Sets the given <code>classpathEntries</code> to the <code>eclipseJavaProject</code>. * * @param eclipseJavaProject// ww w. j av a2 s. c o m * @param classpathEntries */ static public void setRawClassPath(IJavaProject eclipseJavaProject, IClasspathEntry[] classpathEntries) { if (null == eclipseJavaProject) throw new IllegalArgumentException("Can't add classpath entries to undefined project!"); if (null == classpathEntries) throw new IllegalArgumentException("Can't add undefined classpath entries to the project!"); if (0 == classpathEntries.length) return; try { eclipseJavaProject.setRawClasspath(classpathEntries, new NullProgressMonitor()); } catch (JavaModelException e) { _log.error(e.getMessage(), e); } }
From source file:net.rim.ejde.internal.util.ResourceBuilderUtils.java
License:Open Source License
/** * Creates the resource output root folder if it is not there. * * @param project// w w w . j a va 2s. co m * @param monitor * @throws CoreException * */ public static IFolder createResourcesOutputRoot(IProject project, IProgressMonitor monitor) throws CoreException { IContainer sourceContainer = project .getFolder(ImportUtils.getImportPref(ResourceBuilder.LOCALE_INTERFACES_FOLDER_NAME)); if (!sourceContainer.exists()) { // if the folder does not exist, create it ((IFolder) sourceContainer).create(IResource.DERIVED, true, monitor); } IJavaProject javaProject = JavaCore.create(project); // check if folder is on classpath already (can occur if project is on classpath if (!javaProject.isOnClasspath(sourceContainer)) { IClasspathEntry tmpSourceRootEntry = JavaCore.newSourceEntry(sourceContainer.getFullPath()); // Set raw classpath IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); IClasspathEntry[] newClasspathEntries = new IClasspathEntry[classpathEntries.length + 1]; System.arraycopy(classpathEntries, 0, newClasspathEntries, 0, classpathEntries.length); newClasspathEntries[classpathEntries.length] = tmpSourceRootEntry; javaProject.setRawClasspath(newClasspathEntries, monitor); } return (IFolder) sourceContainer; }
From source file:net.roamstudio.roamflow.wizard.NewProjectWizard.java
License:Open Source License
private void setClasspath(IJavaProject javaProject) throws JavaModelException, CoreException { javaProject.setRawClasspath(new IClasspathEntry[0], null); addSourceFolders(javaProject);/*from w ww. j a v a 2 s . c o m*/ addJRELibraries(javaProject); addJbpmLibraries(javaProject); }
From source file:net.roamstudio.roamflow.wizard.NewProjectWizard.java
License:Open Source License
private void addJRELibraries(IJavaProject javaProject) throws JavaModelException { List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); entries.addAll(Arrays.asList(javaProject.getRawClasspath())); entries.addAll(Arrays.asList(PreferenceConstants.getDefaultJRELibrary())); javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); }
From source file:net.roamstudio.roamflow.wizard.NewProjectWizard.java
License:Open Source License
private void addSourceFolders(IJavaProject javaProject) throws JavaModelException, CoreException { List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); entries.addAll(Arrays.asList(javaProject.getRawClasspath())); addSourceFolder(javaProject, entries, "src/process"); //$NON-NLS-1$ javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); }
From source file:net.roamstudio.roamflow.wizard.NewProjectWizard.java
License:Open Source License
private void addJbpmLibraries(IJavaProject javaProject) throws JavaModelException { createJbpmLibraryContainer(javaProject); List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); entries.addAll(Arrays.asList(javaProject.getRawClasspath())); entries.add(JavaCore.newContainerEntry(getClassPathContainerPath())); javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); }
From source file:net.sf.eclipse.tomcat.TomcatLauncherPlugin.java
License:Open Source License
/** * Remove TOMCAT_HOME variable from Tomcat projects build path * (Eclipse 3 will not compile Tomcat projects without this fix) *//* w ww. j a va2 s .c om*/ private void fixTomcatHomeBug() { if (this.getPreferenceStore().getString("fixTomcatHomeBug").equals("")) { this.getPreferenceStore().setValue("fixTomcatHomeBug", "fixed"); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject[] projects = root.getProjects(); try { for (IProject project : projects) { if (project.hasNature(NATURE_ID)) { List cp = new ArrayList(projects.length - 1); IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] classpath = javaProject.getRawClasspath(); cp.addAll(Arrays.asList(classpath)); for (IClasspathEntry element : classpath) { if (element.getEntryKind() == IClasspathEntry.CPE_VARIABLE) { if (element.getPath().equals(TomcatLauncherPlugin.getDefault().getTomcatIPath())) { cp.remove(element); } } } javaProject.setRawClasspath((IClasspathEntry[]) cp.toArray(new IClasspathEntry[cp.size()]), null); } } } catch (Exception e) { log(e); } } }