List of usage examples for org.eclipse.jdt.core IJavaProject getRawClasspath
IClasspathEntry[] getRawClasspath() throws JavaModelException;
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//from w w w . j a v a2 s.c om * @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 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.TomcatBootstrap.java
License:Open Source License
private void getClassPathEntries(IJavaProject prj, ArrayList data, List selectedPaths, ArrayList visitedProjects) { IClasspathEntry[] entries = null;/*www .j a v a2 s . co m*/ IPath outputPath = null; try { outputPath = prj.getOutputLocation(); if (selectedPaths.contains(outputPath.toFile().toString().replace('\\', '/'))) { add(data, prj.getProject().getWorkspace().getRoot().findMember(outputPath)); } entries = prj.getRawClasspath(); } catch (JavaModelException e) { TomcatLauncherPlugin.log(e); } if (entries != null) { getClassPathEntries(entries, prj, data, selectedPaths, visitedProjects, outputPath); } }
From source file:net.sf.eclipse.tomcat.TomcatBootstrap.java
License:Open Source License
private void collectMavenDependencies(IJavaProject prj, List data, List visitedProjects) { IClasspathEntry[] entries = null;/*w w w. j a v a2s . c o m*/ try { add(data, prj.getProject().getWorkspace().getRoot().findMember(prj.getOutputLocation())); entries = prj.getRawClasspath(); } catch (JavaModelException e) { TomcatLauncherPlugin.log(e); } if (entries != null) { collectMavenDependencies(entries, prj, data, visitedProjects); } }
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) *//*from w w w . ja va2 s. c o m*/ 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); } } }
From source file:net.sf.eclipse.tomcat.TomcatProjectWebclasspathPropertyPage.java
License:Open Source License
public void getClassPathEntries(IJavaProject prj, ArrayList data) { IClasspathEntry[] myEntries = null;/* ww w . j a v a 2 s .com*/ IPath outputPath = null; try { outputPath = prj.getOutputLocation(); add(data, prj.getOutputLocation()); myEntries = prj.getRawClasspath(); } catch (JavaModelException e) { TomcatLauncherPlugin.log(e); } if (myEntries != null) { getClassPathEntries(myEntries, prj, data, outputPath); } }
From source file:net.sf.jasperreports.eclipse.classpath.OutputFolderClassLoader.java
License:Open Source License
private byte[] loadClassData(String className, IJavaProject javaProject) throws Exception { IPath defaultLocationPath = javaProject.getOutputLocation(); IWorkspaceRoot wsRoot = javaProject.getProject().getWorkspace().getRoot(); IFolder folder = wsRoot.getFolder(defaultLocationPath); String prjDefaultLocation = folder.getLocation().toOSString(); byte[] classBytes = loadClassFile(prjDefaultLocation + "/" + className.replaceAll("\\.", "/") + ".class"); if (classBytes == null) { // Iterate over the (possible) output locations of the sourcefolder classpath entries IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); for (IClasspathEntry e : classpathEntries) { if (e.getContentKind() == IPackageFragmentRoot.K_SOURCE) { IPath entryOutputLocation = e.getOutputLocation(); if (entryOutputLocation != null) { IFolder entryOutputFolder = wsRoot.getFolder(entryOutputLocation); classBytes = loadClassFile( entryOutputFolder + "/" + className.replaceAll("\\.", "/") + ".class"); if (classBytes != null) break; }/*from w ww .j a va 2 s . c o m*/ } } } return classBytes; }
From source file:net.sf.jasperreports.samples.wizards.SampleNewWizard.java
License:Open Source License
private static void addLibraries(Set<String> lpaths, IJavaProject project, IProgressMonitor monitor) { if (lpaths.isEmpty()) return;//from w w w . j av a 2 s .c o m try { IClasspathEntry[] cpentries = project.getRawClasspath(); IClasspathEntry[] newEntries = new IClasspathEntry[cpentries.length + lpaths.size()]; System.arraycopy(cpentries, 0, newEntries, 0, cpentries.length); int i = cpentries.length; for (String cp : lpaths) { newEntries[i] = JavaCore.newLibraryEntry(project.getProject().getFile(cp).getFullPath(), null, null); i++; if (monitor.isCanceled()) return; } project.setRawClasspath(newEntries, monitor); } catch (JavaModelException e) { e.printStackTrace(); } }