List of usage examples for org.eclipse.jdt.core IClasspathEntry isExported
boolean isExported();
From source file:org.jboss.tools.common.jdt.core.buildpath.MaterializeLibraryJob.java
License:Open Source License
private IClasspathEntry getNewClasspathEntry(IClasspathEntry entry, IPath destinationFilePath) throws CoreException { try {/*from w w w .ja va 2s .c o m*/ return JavaCore.newLibraryEntry(destinationFilePath, (keepSourceAttachments) ? entry.getSourceAttachmentPath() : null, (keepSourceAttachments) ? entry.getSourceAttachmentRootPath() : null, entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } catch (Exception e) { IStatus status = new Status(IStatus.ERROR, JDTExtActivator.PLUGIN_ID, NLS.bind(Messages.MaterializeLibraryJob_Error_creating_classpath_entry, e.getMessage()), e); throw new CoreException(status); } }
From source file:org.jboss.tools.m2e.extras.AptBuildParticipant.java
License:Open Source License
private void processClasspathElement(IClasspathEntry ice, IProject containingProject, Xpp3Dom newClasspathElementsDom) throws JavaModelException { IPath path;//w w w . ja va 2s . c om switch (ice.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: { path = ice.getOutputLocation(); if (path == null) { path = JavaCore.create(containingProject).getOutputLocation(); } break; } case IClasspathEntry.CPE_PROJECT: { IProject referenceProject = containingProject.getWorkspace().getRoot() .getProject(ice.getPath().toPortableString()); for (IClasspathEntry resolvedIce : JavaCore.create(referenceProject).getRawClasspath()) { // we're only concerned with exported libraries and the project // output if (resolvedIce.isExported() || resolvedIce.getEntryKind() == IClasspathEntry.CPE_SOURCE) { try { processClasspathElement(resolvedIce, referenceProject, newClasspathElementsDom); } catch (JavaModelException e) { } } } return; } case IClasspathEntry.CPE_CONTAINER: { // we're only concerned with the PDE container if (!PDE_CLASSPATH_CONTAINER.equals(ice.getPath())) { return; } IClasspathContainer icc = JavaCore.getClasspathContainer(ice.getPath(), JavaCore.create(containingProject)); if (icc == null) { return; } for (IClasspathEntry resolvedIce : icc.getClasspathEntries()) { try { processClasspathElement(resolvedIce, containingProject, newClasspathElementsDom); } catch (JavaModelException e) { } } return; } case IClasspathEntry.CPE_LIBRARY: path = ice.getPath(); break; case IClasspathEntry.CPE_VARIABLE: ice = JavaCore.getResolvedClasspathEntry(ice); if (ice == null) { return; } path = ice.getPath(); break; default: return; } // make sure we have an absolute file system path Xpp3Dom child = new Xpp3Dom("#"); IResource resource = containingProject.getWorkspace().getRoot().findMember(path); if (resource == null) { child.setValue(ice.getPath().toPortableString()); } else { child.setValue(resource.getLocation().toPortableString()); } newClasspathElementsDom.addChild(child); }
From source file:org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.java
License:Open Source License
public static boolean removeReferencedLibrarySourceAttachment(IJavaProject javaProject, String name, IProgressMonitor progressMonitor) throws OperationCanceledException, CoreException, InterruptedException { IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); boolean found = false; for (int i = 0; i < classpathEntries.length; i++) { IClasspathEntry classpathEntry = classpathEntries[i]; IPath path = classpathEntry.getPath(); if (path.toFile().getAbsolutePath().contains(name)) { if (!path.isAbsolute()) { path = JavaCore.getClasspathVariable("M2_REPO") .append(path.makeRelativeTo(new Path("M2_REPO"))); }/* w w w. ja v a 2 s . c om*/ classpathEntries[i] = JavaCore.newLibraryEntry(path, null, null, classpathEntry.getAccessRules(), classpathEntry.getExtraAttributes(), classpathEntry.isExported()); found = true; } } javaProject.setRawClasspath(classpathEntries, progressMonitor); // refresh/build project WorkbenchTasks.buildProject(javaProject.getProject(), progressMonitor); return found; }
From source file:org.jetbrains.kotlin.core.utils.ProjectUtils.java
License:Apache License
@NotNull private static List<File> expandDependentProjectClasspath(@NotNull IClasspathEntry projectEntry, boolean includeBinFolders, @NotNull Predicate<IClasspathEntry> entryPredicate) throws JavaModelException { IPath projectPath = projectEntry.getPath(); IProject dependentProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectPath.toString()); IJavaProject javaProject = JavaCore.create(dependentProject); Set<File> orderedFiles = Sets.newLinkedHashSet(); for (IClasspathEntry classpathEntry : javaProject.getResolvedClasspath(true)) { if (!(classpathEntry.isExported() || classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE)) { continue; }//from www .ja v a2 s. c o m if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { orderedFiles .addAll(expandDependentProjectClasspath(classpathEntry, includeBinFolders, entryPredicate)); } else { if (entryPredicate.apply(classpathEntry)) { orderedFiles.addAll(getFileByEntry(classpathEntry, javaProject)); } } } if (includeBinFolders) { IFolder outputFolder = ProjectUtils.getOutputFolder(javaProject); if (outputFolder != null && outputFolder.exists()) { orderedFiles.add(outputFolder.getLocation().toFile()); } } return Lists.newArrayList(orderedFiles); }
From source file:org.maven.ide.eclipse.scala.ScalaProjectConfigurator.java
License:Open Source License
private static void addDeployableAttribute(IJavaProject javaProject, IClasspathAttribute deployableAttribute, IProgressMonitor monitor) throws JavaModelException, CoreException { if (javaProject == null) return;//from www .j av a 2s .c om ClasspathContainerInitializer scalaInitializer = JavaCore .getClasspathContainerInitializer(SCALA_CONTAINER_PATH); if (scalaInitializer == null) return; IPath scalaContainerPath = Path.fromPortableString(SCALA_CONTAINER_PATH); Boolean updateAble = scalaInitializer.canUpdateClasspathContainer(scalaContainerPath, javaProject); final IClasspathContainer scalaLibrary = JavaCore.getClasspathContainer(scalaContainerPath, javaProject); final IClasspathEntry[] cpEntries = scalaLibrary.getClasspathEntries(); for (int i = 0; i < cpEntries.length; i++) { IClasspathEntry cpe = cpEntries[i]; LinkedHashMap<String, IClasspathAttribute> attrs = new LinkedHashMap<String, IClasspathAttribute>(); for (IClasspathAttribute attr : cpe.getExtraAttributes()) { //Keep all existing attributes except the non_deployable key if (!attr.getName().equals(NON_DEPLOYABLE_KEY)) { attrs.put(attr.getName(), attr); } } attrs.put(deployableAttribute.getName(), deployableAttribute); IClasspathAttribute[] newAttrs = attrs.values().toArray(new IClasspathAttribute[attrs.size()]); cpEntries[i] = JavaCore.newLibraryEntry(cpe.getPath(), cpe.getSourceAttachmentPath(), cpe.getSourceAttachmentRootPath(), cpe.getAccessRules(), newAttrs, cpe.isExported()); } IClasspathContainer candidateScalaContainer = new IClasspathContainer() { public IPath getPath() { return scalaLibrary.getPath(); } public IClasspathEntry[] getClasspathEntries() { return cpEntries; } public String getDescription() { return scalaLibrary.getDescription(); } public int getKind() { return scalaLibrary.getKind(); } }; if (updateAble) { scalaInitializer.requestClasspathContainerUpdate(scalaContainerPath, javaProject, candidateScalaContainer); } else { IJavaProject[] jPArray = { javaProject }; IClasspathContainer[] cpArray = { candidateScalaContainer }; JavaCore.setClasspathContainer(scalaContainerPath, jPArray, cpArray, null); } }
From source file:org.neuro4j.studio.core.util.ClassloaderHelper.java
License:Apache License
private static void collectClasspathURLs(IJavaProject javaProject, List<URL> urls, Set<IJavaProject> visited, boolean isFirstProject) { if (visited.contains(javaProject)) return;/*w ww . j av a 2 s. c o m*/ visited.add(javaProject); IPath outPath = getJavaProjectOutputAbsoluteLocation(javaProject.getProject()); if (outPath != null) { outPath = outPath.addTrailingSeparator(); URL out = createFileURL(outPath); urls.add(out); } IClasspathEntry[] entries = null; try { entries = javaProject.getResolvedClasspath(true); } catch (JavaModelException e) { return; } IClasspathEntry entry; for (int i = 0; i < entries.length; i++) { entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: collectClasspathEntryURL(entry, urls); break; case IClasspathEntry.CPE_CONTAINER: case IClasspathEntry.CPE_VARIABLE: collectClasspathEntryURL(entry, urls); break; case IClasspathEntry.CPE_PROJECT: { if (isFirstProject || entry.isExported()) collectClasspathURLs(getJavaProject(entry), urls, visited, false); break; } } } }
From source file:org.neuro4j.studio.core.util.ClassloaderHelper.java
License:Apache License
private static void collectClasspathIPath(IJavaProject javaProject, List<IPath> urls, Set<IJavaProject> visited, boolean isFirstProject) { if (visited.contains(javaProject)) return;//from ww w. j a va 2 s. c o m visited.add(javaProject); IClasspathEntry[] entries = null; try { entries = javaProject.getResolvedClasspath(true); } catch (JavaModelException e) { return; } IClasspathEntry entry; for (int i = 0; i < entries.length; i++) { entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: addJarToList(entry.getPath(), urls); break; case IClasspathEntry.CPE_CONTAINER: case IClasspathEntry.CPE_SOURCE: break; case IClasspathEntry.CPE_VARIABLE: addJarToList(entry.getPath(), urls); break; case IClasspathEntry.CPE_PROJECT: { if (isFirstProject || entry.isExported()) collectClasspathIPath(getJavaProject(entry), urls, visited, false); break; } } } }
From source file:org.objectstyle.wolips.jrebel.utils.WOProjectClassLoader.java
License:BSD License
private void addURLs(IJavaProject javaProject, boolean exportsOnly) { if (!javaProjects.contains(javaProject)) { javaProjects.add(javaProject);/*from www. ja v a2s. c o m*/ try { // Add default output location addURL(javaProject.getOutputLocation()); // Add each classpath entry IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true); for (IClasspathEntry classpathEntry : classpathEntries) { if (classpathEntry.isExported() || !exportsOnly) { switch (classpathEntry.getEntryKind()) { // Recurse on projects case IClasspathEntry.CPE_PROJECT: IProject project = javaProject.getProject().getWorkspace().getRoot() .getProject(classpathEntry.getPath().toString()); IJavaProject javaProj = JavaCore.create(project); if (javaProj != null) { addURLs(javaProj, true); } break; // Library case IClasspathEntry.CPE_LIBRARY: addURL(classpathEntry); break; // Only Source entries with custom output location need to be added case IClasspathEntry.CPE_SOURCE: IPath outputLocation = classpathEntry.getOutputLocation(); if (outputLocation != null) { addURL(outputLocation); } break; // Variable and Container entries should not be happening, because // we've asked for resolved entries. case IClasspathEntry.CPE_VARIABLE: case IClasspathEntry.CPE_CONTAINER: break; } } } } catch (JavaModelException e) { e.printStackTrace(); // log.debug("MalformedURLException occurred: " + e.getLocalizedMessage(),e); } } }
From source file:org.openscada.eclipse.classpath.dir.ui.ClassPathContainerPageImpl.java
License:Open Source License
public void setSelection(final IClasspathEntry containerEntry) { if (containerEntry != null) { this.exported = containerEntry.isExported(); this.path = Helper.getPath(containerEntry.getPath()); }//from www . j a va2 s . c o m }
From source file:org.seasar.diigu.eclipse.util.JavaProjectClassLoader.java
License:Apache License
protected void addClasspathEntries(IJavaProject project, Set already, boolean atFirst) { already.add(project);/*from ww w.java 2 s. com*/ try { IContainer workspaceroot = project.getProject().getParent(); IPath path = project.getOutputLocation(); addURL(toURL(workspaceroot.getFolder(path).getLocation())); IClasspathEntry[] entries = project.getResolvedClasspath(true); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: IPath dist = entry.getOutputLocation(); if (dist != null) { addURL(toURL(workspaceroot.getFolder(dist).getLocation())); } break; case IClasspathEntry.CPE_LIBRARY: case IClasspathEntry.CPE_CONTAINER: case IClasspathEntry.CPE_VARIABLE: IPath p = entry.getPath(); if (p.toFile().exists()) { addURL(toURL(p)); } else { addURL(toURL(workspaceroot.getFile(p).getLocation())); } break; case IClasspathEntry.CPE_PROJECT: IJavaProject proj = ProjectUtils.getJavaProject(entry.getPath().segment(0)); if (proj != null && proj.exists() && already.contains(proj) == false && (atFirst || entry.isExported())) { addClasspathEntries(proj, already, false); } break; default: break; } } } catch (Exception e) { DiiguPlugin.log(e); } }