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:at.bestsolution.javafx.ide.jdt.internal.jdt.CPListElement.java
License:Open Source License
public static CPListElement create(Object parent, IClasspathEntry curr, boolean newElement, IJavaProject project) {/*from w ww. j ava 2s .c o m*/ IPath path = curr.getPath(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // get the resource IResource res = null; boolean isMissing = false; IPath linkTarget = null; switch (curr.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: try { isMissing = project != null && (JavaCore.getClasspathContainer(path, project) == null); } catch (JavaModelException e) { isMissing = true; } break; case IClasspathEntry.CPE_VARIABLE: IPath resolvedPath = JavaCore.getResolvedVariablePath(path); isMissing = root.findMember(resolvedPath) == null && !resolvedPath.toFile().exists(); break; case IClasspathEntry.CPE_LIBRARY: res = root.findMember(path); if (res == null) { if (!ArchiveFileFilter.isArchivePath(path, true)) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK() && root.getProject(path.segment(0)).exists()) { res = root.getFolder(path); } } IPath rawPath = path; if (project != null) { IPackageFragmentRoot[] roots = project.findPackageFragmentRoots(curr); if (roots.length == 1) rawPath = roots[0].getPath(); } isMissing = !rawPath.toFile().exists(); // look for external JARs and folders } else if (res.isLinked()) { linkTarget = res.getLocation(); } break; case IClasspathEntry.CPE_SOURCE: path = path.removeTrailingSeparator(); res = root.findMember(path); if (res == null) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) { res = root.getFolder(path); } isMissing = true; } else if (res.isLinked()) { linkTarget = res.getLocation(); } break; case IClasspathEntry.CPE_PROJECT: res = root.findMember(path); isMissing = (res == null); break; } CPListElement elem = new CPListElement(parent, project, curr.getEntryKind(), path, newElement, res, linkTarget); elem.setExported(curr.isExported()); elem.setAttribute(SOURCEATTACHMENT, curr.getSourceAttachmentPath()); elem.setAttribute(OUTPUT, curr.getOutputLocation()); elem.setAttribute(EXCLUSION, curr.getExclusionPatterns()); elem.setAttribute(INCLUSION, curr.getInclusionPatterns()); elem.setAttribute(ACCESSRULES, curr.getAccessRules()); elem.setAttribute(COMBINE_ACCESSRULES, new Boolean(curr.combineAccessRules())); IClasspathAttribute[] extraAttributes = curr.getExtraAttributes(); for (int i = 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib = extraAttributes[i]; CPListElementAttribute attribElem = elem.findAttributeElement(attrib.getName()); if (attribElem == null) { elem.createAttributeElement(attrib.getName(), attrib.getValue(), false); } else { attribElem.setValue(attrib.getValue()); } } elem.setIsMissing(isMissing); return elem; }
From source file:ccw.builder.ClojureBuilder.java
License:Open Source License
private static Map<IFolder, IFolder> getSrcFolders(IProject project) throws CoreException { Map<IFolder, IFolder> srcFolders = new HashMap<IFolder, IFolder>(); IJavaProject jProject = JavaCore.create(project); IClasspathEntry[] entries = jProject.getResolvedClasspath(true); IPath defaultOutputFolder = jProject.getOutputLocation(); for (IClasspathEntry entry : entries) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: IFolder folder = project.getWorkspace().getRoot().getFolder(entry.getPath()); IFolder outputFolder = project.getWorkspace().getRoot().getFolder( (entry.getOutputLocation() == null) ? defaultOutputFolder : entry.getOutputLocation()); if (folder.exists()) srcFolders.put(folder, outputFolder); break; case IClasspathEntry.CPE_LIBRARY: break; case IClasspathEntry.CPE_PROJECT: // TODO should compile here ? break; case IClasspathEntry.CPE_CONTAINER: case IClasspathEntry.CPE_VARIABLE: // Impossible cases, since entries are resolved default:/* w ww . j a va2s . c om*/ break; } } return srcFolders; }
From source file:com.cisco.yangide.core.indexing.DeltaProcessor.java
License:Open Source License
private OutputsInfo outputsInfo(IResource res) { try {//from w w w . j a v a 2 s . c om JavaProject proj = (JavaProject) JavaCore.create(res.getProject()); if (proj != null) { IPath projectOutput = proj.getOutputLocation(); int traverseMode = IGNORE; if (proj.getProject().getFullPath().equals(projectOutput)) { // case of // proj==bin==src return new OutputsInfo(new IPath[] { projectOutput }, new int[] { SOURCE }, 1); } IClasspathEntry[] classpath = proj.getResolvedClasspath(); IPath[] outputs = new IPath[classpath.length + 1]; int[] traverseModes = new int[classpath.length + 1]; int outputCount = 1; outputs[0] = projectOutput; traverseModes[0] = traverseMode; for (int i = 0, length = classpath.length; i < length; i++) { IClasspathEntry entry = classpath[i]; IPath entryPath = entry.getPath(); IPath output = entry.getOutputLocation(); if (output != null) { outputs[outputCount] = output; // check case of src==bin if (entryPath.equals(output)) { traverseModes[outputCount++] = (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) ? SOURCE : BINARY; } else { traverseModes[outputCount++] = IGNORE; } } // check case of src==bin if (entryPath.equals(projectOutput)) { traverseModes[0] = (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) ? SOURCE : BINARY; } } return new OutputsInfo(outputs, traverseModes, outputCount); } } catch (JavaModelException e) { // java project doesn't exist: ignore } return null; }
From source file:com.cisco.yangide.core.indexing.IndexAllProject.java
License:Open Source License
@Override public boolean execute(IProgressMonitor progressMonitor) { System.err.println("[I] Project: " + project.getName()); if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) { return true; }//from w w w . java2 s . c o m if (!this.project.isAccessible()) { return true; } final HashSet<IPath> ignoredPath = new HashSet<IPath>(); final HashSet<IPath> externalJarsPath = new HashSet<IPath>(); try { JavaProject proj = (JavaProject) JavaCore.create(project); final HashSet<String> projectScope = new HashSet<>(); projectScope.add(project.getName()); if (proj != null) { IClasspathEntry[] classpath = proj.getResolvedClasspath(); for (int i = 0, length = classpath.length; i < length; i++) { IClasspathEntry entry = classpath[i]; 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 (int i = 0, length = roots.length; i < length; i++) { IPath entryPath = roots[i].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 HashSet<String> indirectScope = new HashSet<String>(); 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 iPath : externalJarsPath) { try (JarFile jarFile = new JarFile(iPath.toFile())) { ZipEntry entry = jarFile.getEntry("META-INF/yang/"); if (entry != null) { this.manager.addJarFile(project, iPath); } } catch (IOException e) { YangCorePlugin.log(e); } } try { final HashSet<IFile> indexedFiles = new HashSet<IFile>(); project.accept(new IResourceProxyVisitor() { @Override public boolean visit(IResourceProxy 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 iFile : indexedFiles) { this.manager.addSource(iFile); } } catch (CoreException e) { this.manager.removeIndexFamily(project); return false; } return true; }
From source file:com.codenvy.ide.ext.java.server.internal.core.JavaProjectElementInfo.java
License:Open Source License
private boolean isClasspathEntryOrOutputLocation(IPath path, IPath location, IClasspathEntry[] resolvedClasspath, IPath projectOutput) { if (projectOutput.equals(path)) return true; for (int i = 0, length = resolvedClasspath.length; i < length; i++) { IClasspathEntry entry = resolvedClasspath[i]; IPath entryPath;/* w w w . j a v a 2 s . c om*/ if ((entryPath = entry.getPath()).equals(path) || entryPath.equals(location)) { return true; } IPath output; if ((output = entry.getOutputLocation()) != null && output.equals(path)) { return true; } } return false; }
From source file:com.github.ko2ic.plugin.eclipse.taggen.core.service.WorkspaceClassLoader.java
License:Open Source License
private Set<URL> createUrls(IJavaProject javaProject) throws CoreException, MalformedURLException { Set<URL> urlList = new HashSet<>(); IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true); for (IClasspathEntry entry : classpathEntries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = entry.getOutputLocation(); if (path != null) { IPath outputPath = javaProject.getOutputLocation().removeFirstSegments(1); IPath outputFullPath = javaProject.getProject().getFolder(outputPath).getLocation(); outputFullPath.append(System.getProperty("line.separator")); URL url = outputFullPath.toFile().toURI().toURL(); urlList.add(url);/* www .j av a2s . co m*/ } } else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { URL url = entry.getPath().toFile().toURI().toURL(); urlList.add(url); } } return urlList; }
From source file:com.google.appengine.eclipse.core.orm.enhancement.AutoEnhancer.java
License:Open Source License
private static IPath getOutputLocation(IClasspathEntry classpathEntry, IPath defaultOutputLocation) { IPath outputFolder = classpathEntry.getOutputLocation(); if (outputFolder == null) { outputFolder = defaultOutputLocation; }//from w ww .j a va2 s.c om return outputFolder; }
From source file:com.google.gdt.eclipse.core.projects.ProjectChangeTimestampTracker.java
License:Open Source License
private static boolean isResourceInAnOutputPath(IResource resource) throws JavaModelException { IProject project = resource.getProject(); IJavaProject javaProject = JavaCore.create(project); if (javaProject != null) { IPath resourcePath = resource.getFullPath(); if (WebAppUtilities.isWebApp(project)) { if (WebAppUtilities.hasManagedWarOut(project) && WebAppUtilities.getManagedWarOut(project).getFullPath().isPrefixOf(resourcePath)) { return true; }/*from w w w .ja v a 2 s . co m*/ IPath previousWarOutAbsPath = WebAppProjectProperties.getLastUsedWarOutLocation(project); if (previousWarOutAbsPath != null && previousWarOutAbsPath.isPrefixOf(resource.getLocation())) { return true; } } if (javaProject.getOutputLocation().isPrefixOf(resourcePath)) { return true; } IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath(false); for (IClasspathEntry classpathEntry : resolvedClasspath) { IPath outputLocation = classpathEntry.getOutputLocation(); if (outputLocation != null && outputLocation.isPrefixOf(resourcePath)) { return true; } } } return false; }
From source file:com.google.gdt.eclipse.designer.actions.deploy.DeployModuleAction.java
License:Open Source License
/** * Returns ANT code for creating jar's for given project itself, coping its jar's from classpath * and calls itself for required projects. */// w ww.j a v a 2 s . co m private static String prepareJars(IProject project, String targetModulePath, boolean addRuntimeJars) throws Exception { String script = ""; // IJavaProject javaProject = JavaCore.create(project); IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots(); // add <jar> task for creating jar from project source and output folders { List<String> sourceLocations = Lists.newArrayList(); List<String> binaryLocations = Lists.newArrayList(); for (IPackageFragmentRoot packageFragmentRoot : roots) { if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) { // add source location sourceLocations.add(packageFragmentRoot.getResource().getLocation().toPortableString()); // add output location { // prepare output location IPath location; { IClasspathEntry cpEntry = packageFragmentRoot.getRawClasspathEntry(); location = cpEntry.getOutputLocation(); if (location == null) { location = javaProject.getOutputLocation(); } } // add absolute location { // remove first segment (project) location = location.removeFirstSegments(1); // prepare absolute location IPath absoluteLocation = project.getLocation().append(location); binaryLocations.add(absoluteLocation.toPortableString()); } } } } // script += "\t\t<!--=== " + project.getName() + " ===-->\n"; script += "\t\t<jar destfile='" + targetModulePath + "/WEB-INF/lib/" + project.getName() + ".jar'>\n"; script += prepareFileSets(sourceLocations, "**"); script += prepareFileSets(binaryLocations, "**/*.class"); script += "\t\t</jar>\n"; } // add <copy> task for coping required runtime jar's if (addRuntimeJars) { String jars = ""; IRuntimeClasspathEntry[] classpathEntries = JavaRuntime.computeUnresolvedRuntimeClasspath(javaProject); for (int entryIndex = 0; entryIndex < classpathEntries.length; entryIndex++) { IRuntimeClasspathEntry entry = classpathEntries[entryIndex]; IRuntimeClasspathEntry[] resolvedEntries = JavaRuntime.resolveRuntimeClasspathEntry(entry, javaProject); for (int resolvedEntryIndex = 0; resolvedEntryIndex < resolvedEntries.length; resolvedEntryIndex++) { IRuntimeClasspathEntry resolvedEntry = resolvedEntries[resolvedEntryIndex]; if (resolvedEntry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES && resolvedEntry.getType() == IRuntimeClasspathEntry.ARCHIVE) { String location = resolvedEntry.getLocation(); // exclude gwt-user.jar, it is in classpath, but it has Servlet class, so can not be in application if (location.endsWith("gwt-user.jar")) { continue; } // add jar file in fileset jars += "\t\t\t<fileset file=\"" + location + "\"/>\n"; } } } // if (jars.length() != 0) { script += "\t\t<copy todir='" + targetModulePath + "/WEB-INF/lib'>\n"; script += jars; script += "\t\t</copy>\n"; } } // add required projects { IProject[] referencedProjects = project.getReferencedProjects(); for (int i = 0; i < referencedProjects.length; i++) { IProject referencedProject = referencedProjects[i]; script += prepareJars(referencedProject, targetModulePath, false); } } // return script; }
From source file:com.google.gwt.eclipse.core.launch.processors.codeserver.SuperDevModeSrcArgumentProcessor.java
License:Open Source License
/** * Get the class path entries that are the source. * * @param javaProject the java project.// ww w . j av a2 s . c o m * @param entry classpath entry value. * @return the path. */ private String getPathIfDir(IJavaProject javaProject, IClasspathEntry entry) { IPath p = entry.getPath(); String projectName = javaProject.getProject().getName(); String path = null; // src directories don't have an output // cpe source are src,test directories if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && (entry.getOutputLocation() == null || (entry.getOutputLocation() != null && !entry.getOutputLocation().lastSegment().toString().equals("test-classes")))) { String dir = p.toString(); // if the base segment has the project name, // lets remove that so its relative to project if (dir.contains(projectName)) { IPath relative = p.removeFirstSegments(1); path = relative.toString(); } } return path; }