@Override public void run(IProgressMonitor monitor) throws CoreException { IClasspathEntry[] oldClasspath= javaProject.getRawClasspath(); int nEntries= oldClasspath.length; IClasspathEntry[] newEntries= Arrays.copyOf(oldClasspath, nEntries+1); newEntries[nEntries]= newEntry; javaProject.setRawClasspath(newEntries, monitor); } };
protected static void addToClasspath(final IJavaProject jproj, final IClasspathEntry entry) throws CoreException { final IClasspathEntry[] current = jproj.getRawClasspath(); final IClasspathEntry[] updated = new IClasspathEntry[current.length + 1]; System.arraycopy(current, 0, updated, 0, current.length); updated[current.length] = entry; jproj.setRawClasspath(updated, null); }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { project.setRawClasspath(newEntries, project.getOutputLocation(), monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } });
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { project.setRawClasspath(newEntries, project.getOutputLocation(), monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } });
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { project.setRawClasspath(newEntries, project.getOutputLocation(), monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } });
private void updateContainers(IProgressMonitor monitor) throws CoreException { List<IClasspathEntry> classpath = Lists.newArrayList(this.project.getRawClasspath()); updateContainers(classpath); this.project.setRawClasspath(classpath.toArray(new IClasspathEntry[classpath.size()]), monitor); }
protected void addSourceFolders(IJavaProject project, IProgressMonitor monitor) throws JavaModelException, CoreException { if (startPage.getInitialProjectContent()!=IKieProjectWizardPage.ONLINE_EXAMPLE_PROJECT) { List<IClasspathEntry> list = new ArrayList<IClasspathEntry>(); list.addAll(Arrays.asList(project.getRawClasspath())); addSourceFolder(project, list, "src/main/java", monitor); addSourceFolder(project, list, "src/main/resources", monitor); project.setRawClasspath((IClasspathEntry[]) list.toArray(new IClasspathEntry[list.size()]), null); } }
public static void removeFromClasspath(IJavaProject from, int entryKind, IPath path) throws CoreException { List<IClasspathEntry> classpath = Lists.newArrayList(from.getRawClasspath()); Iterator<IClasspathEntry> iterator = classpath.iterator(); while (iterator.hasNext()) { IClasspathEntry entry = iterator.next(); if (entry.getEntryKind() == entryKind) { if (entry.getPath().equals(path)) iterator.remove(); } } from.setRawClasspath(classpath.toArray(new IClasspathEntry[classpath.size()]), monitor()); }
private void updateSourceFolders(IProgressMonitor monitor) throws JavaModelException { List<IClasspathEntry> classpath = Lists.newArrayList(this.project.getRawClasspath()); updateExistingSourceFolders(classpath); addNewSourceFolders(classpath); this.project.setRawClasspath(classpath.toArray(new IClasspathEntry[0]), monitor); }
private void addToClassPath(IJavaProject project, IPath jarPath, IProgressMonitor monitor) throws JavaModelException { if (monitor.isCanceled()) throw new OperationCanceledException(); IClasspathEntry[] entries= project.getRawClasspath(); IClasspathEntry[] newEntries= new IClasspathEntry[entries.length + 1]; System.arraycopy(entries, 0, newEntries, 0, entries.length); newEntries[entries.length]= JavaCore.newLibraryEntry(jarPath, null, null, false); project.setRawClasspath(newEntries, monitor); } };
public static void deleteClasspathEntry(IJavaProject javaProject, IPath path) throws JavaModelException { IClasspathEntry[] classpath = javaProject.getRawClasspath(); for (int i = 0; i < classpath.length; ++i) { IPath entryPath = classpath[i].getPath(); if (path.equals(entryPath)) { IClasspathEntry[] newClasspath = new IClasspathEntry[classpath.length - 1]; System.arraycopy(classpath, 0, newClasspath, 0, i); System.arraycopy(classpath, i + 1, newClasspath, i, classpath.length - i - 1); javaProject.setRawClasspath(newClasspath, null); } } }
private void addToClassPath(IJavaProject project, IPath jarPath, IProgressMonitor monitor) throws JavaModelException { if (monitor.isCanceled()) throw new OperationCanceledException(); IClasspathEntry[] entries= project.getRawClasspath(); IClasspathEntry[] newEntries= new IClasspathEntry[entries.length + 1]; System.arraycopy(entries, 0, newEntries, 0, entries.length); newEntries[entries.length]= JavaCore.newLibraryEntry(jarPath, null, null, false); project.setRawClasspath(newEntries, monitor); } };
public static void update(IJavaProject eclipseProject, EclipseProject modelProject, IProgressMonitor monitor) throws JavaModelException { if (supportsClasspathCustomization(modelProject)) { IClasspathEntry[] newClasspath = filterLibraries(eclipseProject.getRawClasspath()); eclipseProject.setRawClasspath(newClasspath, monitor); } }
private void createPackageFragmentRoot(IPackageFragmentRoot root) throws CoreException { final IJavaProject project= root.getJavaProject(); if (!project.exists()) { // createJavaProject(project.getProject()); } final IFolder folder= project.getProject().getFolder(root.getElementName()); if (!folder.exists()) { ResourceUtil.createFolder(folder, true, true, new NullProgressMonitor()); } final List<IClasspathEntry> list= Arrays.asList(project.getRawClasspath()); list.add(JavaCore.newSourceEntry(folder.getFullPath())); project.setRawClasspath(list.toArray(new IClasspathEntry[list.size()]), new NullProgressMonitor()); }
private void createPackageFragmentRoot(IPackageFragmentRoot root) throws CoreException { final IJavaProject project= root.getJavaProject(); if (!project.exists()) createJavaProject(project.getProject()); final IFolder folder= project.getProject().getFolder(root.getElementName()); if (!folder.exists()) CoreUtility.createFolder(folder, true, true, new NullProgressMonitor()); final List<IClasspathEntry> list= Arrays.asList(project.getRawClasspath()); list.add(JavaCore.newSourceEntry(folder.getFullPath())); project.setRawClasspath(list.toArray(new IClasspathEntry[list.size()]), new NullProgressMonitor()); }
private void createPackageFragmentRoot(IPackageFragmentRoot root) throws CoreException { final IJavaProject project= root.getJavaProject(); if (!project.exists()) createJavaProject(project.getProject()); final IFolder folder= project.getProject().getFolder(root.getElementName()); if (!folder.exists()) CoreUtility.createFolder(folder, true, true, new NullProgressMonitor()); final List list= Arrays.asList(project.getRawClasspath()); list.add(JavaCore.newSourceEntry(folder.getFullPath())); project.setRawClasspath((IClasspathEntry[]) list.toArray(new IClasspathEntry[list.size()]), new NullProgressMonitor()); }
private void createPackageFragmentRoot(IPackageFragmentRoot root) throws CoreException { final IJavaProject project= root.getJavaProject(); if (!project.exists()) createJavaProject(project.getProject()); final IFolder folder= project.getProject().getFolder(root.getElementName()); if (!folder.exists()) CoreUtility.createFolder(folder, true, true, new NullProgressMonitor()); final List<IClasspathEntry> list= Arrays.asList(project.getRawClasspath()); list.add(JavaCore.newSourceEntry(folder.getFullPath())); project.setRawClasspath(list.toArray(new IClasspathEntry[list.size()]), new NullProgressMonitor()); }
private static void updateReferencedClasspathEntry(IJavaProject javaProject, IClasspathEntry newEntry, IProgressMonitor monitor) throws JavaModelException { List<IClasspathEntry> newEntries = updateElements(javaProject.getReferencedClasspathEntries(), newEntry, (entry) -> { return entry.getEntryKind() == newEntry.getEntryKind() && entry.getPath().equals(newEntry.getPath()); }); javaProject.setRawClasspath(javaProject.getRawClasspath(), newEntries.toArray(new IClasspathEntry[0]), javaProject.getOutputLocation(), monitor); }
private void setClasspath(IProject project, IFeatureModel model, IProgressMonitor monitor) throws JavaModelException { SubMonitor subMonitor = SubMonitor.convert(monitor); IJavaProject jProject = JavaCore.create(project); IClasspathEntry jreCPEntry = JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER")); //$NON-NLS-1$ String libName = model.getFeature().getInstallHandler().getLibrary(); IClasspathEntry handlerCPEntry = JavaCore.newLibraryEntry(project.getFullPath().append(libName), null, null); jProject.setRawClasspath(new IClasspathEntry[] { jreCPEntry, handlerCPEntry }, subMonitor); }
private static void updateProjectClasspath(IJavaProject javaProject, IClasspathEntry newEntry, IProgressMonitor monitor) throws JavaModelException { List<IClasspathEntry> newEntries = updateElements(javaProject.getRawClasspath(), newEntry, (entry) -> { return entry.getEntryKind() == newEntry.getEntryKind() && entry.getPath().equals(newEntry.getPath()); }); JavaLanguageServerPlugin.logInfo("Update source attachment " + (newEntry.getSourceAttachmentPath() == null ? null : newEntry.getSourceAttachmentPath().toOSString()) + " to the file " + newEntry.getPath().toOSString()); javaProject.setRawClasspath(newEntries.toArray(new IClasspathEntry[0]), monitor); }