List of usage examples for org.eclipse.jdt.core IClasspathEntry getOutputLocation
IPath getOutputLocation();
.class
files generated for this source entry (entry kind #CPE_SOURCE ). 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);// w w w .j a v a2 s.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.opendaylight.yangide.core.indexing.IndexAllProject.java
License:Open Source License
@Override public boolean execute(IProgressMonitor progressMonitor) { log.info("[I] Project: {}", project.getName()); if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) { return true; }//from w ww . ja v a 2 s . c om if (!this.project.isAccessible()) { return true; } final Set<IPath> ignoredPath = new HashSet<>(); final Set<IPath> externalJarsPath = new HashSet<>(); try { JavaProject proj = (JavaProject) JavaCore.create(project); final Set<String> projectScope = new HashSet<>(); projectScope.add(project.getName()); if (proj != null) { IClasspathEntry[] classpath = proj.getResolvedClasspath(); for (IClasspathEntry entry : classpath) { IPath entryPath = entry.getPath(); IPath output = entry.getOutputLocation(); if (output != null && !entryPath.equals(output)) { ignoredPath.add(output); } // index dependencies projects if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IProject prj = ResourcesPlugin.getWorkspace().getRoot() .getProject(entry.getPath().lastSegment()); if (prj != null && prj.exists()) { this.manager.indexAll(prj); projectScope.add(prj.getName()); } } } IPackageFragmentRoot[] roots = proj.getAllPackageFragmentRoots(); for (IPackageFragmentRoot root : roots) { IPath entryPath = root.getPath(); if (entryPath != null && entryPath.toFile().exists() && entryPath.lastSegment().toLowerCase().endsWith(".jar")) { externalJarsPath.add(entryPath); } } // Update project information with set of project dependencies YangProjectInfo yangProjectInfo = (YangProjectInfo) YangCorePlugin.create(project) .getElementInfo(null); yangProjectInfo.setProjectScope(projectScope); // fill indirect scope Set<String> indirectScope = new HashSet<>(); indirectScope.add(project.getName()); for (IJavaProject jproj : JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()) .getJavaProjects()) { if (jproj != proj) { for (String name : jproj.getRequiredProjectNames()) { if (name.equals(project.getName())) { indirectScope.add(jproj.getProject().getName()); } } } } yangProjectInfo.setIndirectScope(indirectScope); } } catch (JavaModelException | YangModelException e) { // java project doesn't exist: ignore } for (IPath path : externalJarsPath) { try (JarFile jarFile = new JarFile(path.toFile())) { ZipEntry entry = jarFile.getEntry("META-INF/yang/"); if (entry != null) { this.manager.addJarFile(project, path); } } catch (IOException e) { YangCorePlugin.log(e); } } try { final HashSet<IFile> indexedFiles = new HashSet<>(); project.accept(proxy -> { if (IndexAllProject.this.isCancelled) { return false; } if (!ignoredPath.isEmpty() && ignoredPath.contains(proxy.requestFullPath())) { return false; } if (proxy.getType() == IResource.FILE) { if (CoreUtil.isYangLikeFileName(proxy.getName())) { IFile file = (IFile) proxy.requestResource(); indexedFiles.add(file); } return false; } return true; }, IResource.NONE); for (IFile file : indexedFiles) { this.manager.addSource(file); } } catch (CoreException e) { this.manager.removeIndexFamily(project); return false; } return true; }
From source file:org.openoffice.ide.eclipse.java.JavaProjectHandler.java
License:LGPL
/** * {@inheritDoc}// ww w . java2s . c om */ public IFolder[] getBinFolders(IUnoidlProject pUnoidlProject) { ArrayList<IFolder> folders = new ArrayList<IFolder>(); IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); IProject prj = workspace.getProject(pUnoidlProject.getName()); IJavaProject javaPrj = JavaCore.create(prj); try { folders.add(workspace.getFolder(javaPrj.getOutputLocation())); IClasspathEntry[] entries = javaPrj.getRawClasspath(); for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getOutputLocation() != null) { folders.add(workspace.getFolder(entry.getOutputLocation())); } } } catch (JavaModelException e) { } return folders.toArray(new IFolder[folders.size()]); }
From source file:org.robovm.eclipse.internal.ib.IBIntegratorManager.java
License:Open Source License
private LinkedHashSet<File> getOutputLocations(IJavaProject javaProject) throws JavaModelException { LinkedHashSet<File> result = new LinkedHashSet<>(); IProject project = javaProject.getProject(); if (javaProject.getOutputLocation() != null) { File f = project.getFile(javaProject.getOutputLocation().removeFirstSegments(1)).getLocation().toFile(); if (f.exists()) { result.add(f);// w ww.j a v a 2s . c o m } } for (IClasspathEntry cpe : javaProject.getRawClasspath()) { if (cpe.getOutputLocation() != null) { File f = project.getFile(cpe.getOutputLocation().removeFirstSegments(1)).getLocation().toFile(); if (f.exists()) { result.add(f); } } } return result; }
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 . ja v a 2s . c om 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); } }
From source file:org.seasar.diigu.eclipse.util.ProjectUtils.java
License:Apache License
public static IPath[] getOutputLocations(IJavaProject project) throws CoreException { List result = new ArrayList(); result.add(project.getOutputLocation()); IClasspathEntry[] entries = project.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = entry.getOutputLocation(); if (path != null) { result.add(path);/*from ww w .jav a2 s. c o m*/ } } } return (IPath[]) result.toArray(new IPath[result.size()]); }
From source file:org.seasar.eclipse.common.util.ProjectUtil.java
License:Apache License
public static IPath[] getOutputLocations(IJavaProject project) throws CoreException { List<IPath> result = new ArrayList<IPath>(); result.add(project.getOutputLocation()); IClasspathEntry[] entries = project.getRawClasspath(); for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { result.add(entry.getOutputLocation()); }/*from ww w.j av a2 s . c o m*/ } return result.toArray(new IPath[result.size()]); }
From source file:org.seasar.kijimuna.core.util.JavaProjectClassLoader.java
License:Apache License
protected void addClasspathEntries(IJavaProject project, Set already, boolean atFirst) { already.add(project);/*from www . j a va 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 = JavaCore.create(ProjectUtils.getProject(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) { KijimunaCore.reportException(e); } }
From source file:org.sonar.ide.eclipse.internal.jdt.JavaProjectConfigurator.java
License:Open Source License
private void configureJavaProject(IJavaProject javaProject, ProjectDefinition sonarProject) { Properties properties = sonarProject.getProperties(); String javaSource = javaProject.getOption(JavaCore.COMPILER_SOURCE, true); String javaTarget = javaProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true); properties.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, Java.KEY); properties.setProperty("sonar.java.source", javaSource); LOG.info("Source Java version: {}", javaSource); properties.setProperty("sonar.java.target", javaTarget); LOG.info("Target Java version: {}", javaTarget); try {/* ww w. ja v a2 s . c o m*/ IClasspathEntry[] classPath = javaProject.getResolvedClasspath(true); for (IClasspathEntry entry : classPath) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: if (isSourceExcluded(entry)) { break; } String srcDir = getAbsolutePath(javaProject, entry.getPath()); LOG.debug("Source directory: {}", srcDir); sonarProject.addSourceDir(srcDir); if (entry.getOutputLocation() != null) { String binDir = getAbsolutePath(javaProject, entry.getOutputLocation()); LOG.debug("Binary directory: {}", binDir); sonarProject.addBinaryDir(binDir); } break; case IClasspathEntry.CPE_LIBRARY: String libDir = entry.getPath().toOSString(); LOG.debug("Library: {}", libDir); sonarProject.addLibrary(libDir); break; default: LOG.warn("Unhandled ClassPathEntry : {}", entry); break; } } String binDir = getAbsolutePath(javaProject, javaProject.getOutputLocation()); LOG.debug("Default binary directory: {}", binDir); sonarProject.addBinaryDir(binDir); } catch (JavaModelException e) { LOG.error(e.getMessage(), e); } }
From source file:org.sonar.ide.eclipse.jdt.internal.JavaProjectConfigurator.java
License:Open Source License
private void processSourceEntry(IClasspathEntry entry, IJavaProject javaProject, JavaProjectConfiguration context, boolean topProject) throws JavaModelException { String srcDir = getAbsolutePath(entry.getPath()); if (srcDir == null) { LOG.warn("Skipping non existing source entry: {}", entry.getPath().toOSString()); return;/*from ww w. j av a 2 s .c o m*/ } String relativeDir = getRelativePath(javaProject, entry.getPath()); if (relativeDir.toLowerCase().matches(TEST_PATTERN)) { if (topProject) { LOG.debug("Test directory: {}", srcDir); context.testDirs().add(srcDir); } } else { if (topProject) { LOG.debug("Source directory: {}", srcDir); context.sourceDirs().add(srcDir); } if (entry.getOutputLocation() != null) { processOutputDir(entry.getOutputLocation(), context, topProject); } } }