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:com.mountainminds.eclemma.internal.core.instr.ClassFilesStore.java
License:Open Source License
private static IPath getClassFileLocation(IPackageFragmentRoot root) throws JavaModelException { IPath path;/*from w ww .j a v a 2s .c o m*/ if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { IClasspathEntry entry = root.getRawClasspathEntry(); path = entry.getOutputLocation(); if (path == null) { path = root.getJavaProject().getOutputLocation(); } } else { path = root.getPath(); } return path; }
From source file:com.proxiad.emfcustomizer.stylesheet.dsl.contentassist.StylesheetProposalProvider.java
License:Open Source License
/** * For an IJavaProject, browse all the ClasspathEntry and check if theirs * OutputLocation() is corresponding to a given IFolder * /*from w ww . j av a 2 s .com*/ * @param javaProject * an IJavaProject (a project with JAVA nature) * @param folder * a given IFolder * @return returns true if one of the outputLocation in classpathEntry of * the javaProject is equal to a given folder.getFullPath(). */ private boolean checkOutputLocationForEachFolder(IJavaProject javaProject, IFolder folder) { boolean res = false; try { IClasspathEntry[] classpathEntry = javaProject.getRawClasspath(); for (IClasspathEntry iClasspathEntry : classpathEntry) { if (iClasspathEntry.getOutputLocation() != null) { res = iClasspathEntry.getOutputLocation().equals(folder.getFullPath()); } } } catch (JavaModelException e) { // ignore } return res; }
From source file:com.siteview.mde.internal.core.project.BundleProjectDescription.java
License:Open Source License
/** * Creates and returns a bundle claspath specifications for the given source.<library> build * entry//from w w w .ja v a 2s. c o m * * @param project * @param entry * @param binary whether a binary folder (<code>true</code>) or source folder (<code>false</code>) * @return associated bundle classpath specifications or <code>null</code> if a malformed entry * @throws CoreException if unable to access Java build path */ private IBundleClasspathEntry[] getClasspathEntries(IProject project, IBuildEntry entry, boolean binary) throws CoreException { String[] tokens = entry.getTokens(); IPath lib = null; if (binary) { lib = new Path(entry.getName().substring(IBuildEntry.OUTPUT_PREFIX.length())); } else { lib = new Path(entry.getName().substring(IBuildEntry.JAR_PREFIX.length())); } if (tokens != null && tokens.length > 0) { IBundleClasspathEntry[] bces = new IBundleClasspathEntry[tokens.length]; for (int i = 0; i < tokens.length; i++) { IPath path = new Path(tokens[i]); IBundleClasspathEntry spec = null; if (binary) { spec = getBundleProjectService().newBundleClasspathEntry(null, path, lib); } else { IJavaProject jp = JavaCore.create(project); IPath output = null; if (jp.exists()) { IClasspathEntry[] rawClasspath = jp.getRawClasspath(); for (int j = 0; j < rawClasspath.length; j++) { IClasspathEntry cpe = rawClasspath[j]; if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (cpe.getPath().removeFirstSegments(1).equals(path)) { output = cpe.getOutputLocation(); if (output != null) { output = output.removeFirstSegments(1); } break; } } } } spec = getBundleProjectService().newBundleClasspathEntry(path, output, lib); } bces[i] = spec; } return bces; } return null; }
From source file:com.siteview.mde.internal.ui.editor.build.RuntimeInfoSection.java
License:Open Source License
private void refreshOutputKeys() { if (!isJavaProject()) return;//from ww w. j av a2 s .co m IBuildEntry buildEntry = getLibrarySelection(); if (buildEntry == null) return; Set outputFolders = new HashSet(); String[] jarFolders = buildEntry.getTokens(); IPackageFragmentRoot[] sourceFolders = computeSourceFolders(); for (int j = 0; j < jarFolders.length; j++) { IPackageFragmentRoot sourceFolder = getSourceFolder(jarFolders[j], sourceFolders); if (sourceFolder != null) { try { IClasspathEntry entry = sourceFolder.getRawClasspathEntry(); IPath outputPath = entry.getOutputLocation(); if (outputPath == null) { outputFolders.add("bin"); //$NON-NLS-1$ } else { outputPath = outputPath.removeFirstSegments(1); outputFolders.add(outputPath.toString()); } } catch (JavaModelException e) { MDEPlugin.logException(e); } } } if (outputFolders.size() != 0) { String libName = buildEntry.getName().substring(7); IBuildModel buildModel = getBuildModel(); IBuild build = buildModel.getBuild(); String outputName = PROPERTY_OUTPUT_PREFIX + libName; IBuildEntry outputEntry = build.getEntry(outputName); if (outputEntry == null) { outputEntry = buildModel.getFactory().createEntry(outputName); try { build.add(outputEntry); } catch (CoreException e) { MDEPlugin.logException(e); } } setOutputEntryTokens(outputFolders, outputEntry); } }
From source file:com.siteview.mde.internal.ui.properties.SelfHostingPropertyPage.java
License:Open Source License
private String[] getOutputFolders() { IProject project = (IProject) getElement().getAdapter(IProject.class); ArrayList list = new ArrayList(); try {//from www .ja v a 2s .c o m if (project.hasNature(JavaCore.NATURE_ID)) { IJavaProject jProject = JavaCore.create(project); list.add(jProject.getOutputLocation().toString()); IClasspathEntry[] entries = jProject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getContentKind() == IPackageFragmentRoot.K_SOURCE) { IPath path = entry.getOutputLocation(); if (path != null) list.add(path.toString()); } } } } catch (JavaModelException e) { } catch (CoreException e) { } return (String[]) list.toArray(new String[list.size()]); }
From source file:com.sympedia.genfw.util.ClasspathHelper.java
License:Open Source License
public static void collectClasspathURLs(IJavaProject javaProject, List<URL> urls) { try {// w w w . j a v a 2s. c o m collectClasspathUrlOutput(javaProject.getOutputLocation(), urls); IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath(true); for (IClasspathEntry entry : resolvedClasspath) { try { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: collectClasspathUrlOutput(entry.getOutputLocation(), urls); break; case IClasspathEntry.CPE_LIBRARY: File libFile = new File(entry.getPath().toString()); URL url = libFile.toURL(); if (!urls.contains(url)) { // System.out.println("LIB: " + url); urls.add(url); } break; case IClasspathEntry.CPE_PROJECT: String projectName = entry.getPath().segment(0); IJavaProject requiredProject = getJavaProject(projectName); collectClasspathURLs(requiredProject, urls); break; default: throw new RuntimeException(); } } catch (MalformedURLException ex) { ex.printStackTrace(); } } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.technophobia.substeps.syntax.ProjectToSyntaxTransformer.java
License:Open Source License
private Set<String> outputFoldersForProject(final IJavaProject project) { final Set<String> outputFolders = new HashSet<String>(); final IPath projectLocation = projectLocationPath(project); try {// ww w . j ava2 s .c o m final IPath defaultOutputLocation = project.getOutputLocation(); if (defaultOutputLocation != null) { final IPath fullPath = appendPathTo(projectLocation, defaultOutputLocation); if (fullPath.toFile().exists()) { outputFolders.add(fullPath.toOSString()); } } for (final IClasspathEntry entry : project.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { final IPath outputLocation = entry.getOutputLocation(); if (outputLocation != null) { final IPath fullPath = appendPathTo(projectLocation, outputLocation); if (fullPath.toFile().exists()) { outputFolders.add(fullPath.toOSString()); } } } } } catch (final JavaModelException ex) { FeatureEditorPlugin.instance() .warn("Could not get output folder location for project " + project.getElementName()); } return outputFolders; }
From source file:com.temenos.ds.op.xtext.ui.internal.se.JdtBasedProcessorProvider.java
License:Open Source License
private List<URL> getOutputFolders(final IJavaProject javaProject) { try {//from w w w . j av a 2 s .c o m final List<URL> result = CollectionLiterals.<URL>newArrayList(); IPath _outputLocation = javaProject.getOutputLocation(); IPath path = _outputLocation.addTrailingSeparator(); String _string = path.toString(); org.eclipse.emf.common.util.URI _createPlatformResourceURI = org.eclipse.emf.common.util.URI .createPlatformResourceURI(_string, true); String _string_1 = _createPlatformResourceURI.toString(); URL url = new URL(_string_1); result.add(url); IClasspathEntry[] _rawClasspath = javaProject.getRawClasspath(); for (final IClasspathEntry entry : _rawClasspath) { int _entryKind = entry.getEntryKind(); switch (_entryKind) { case IClasspathEntry.CPE_SOURCE: IPath _outputLocation_1 = entry.getOutputLocation(); path = _outputLocation_1; boolean _notEquals = (!Objects.equal(path, null)); if (_notEquals) { IPath _addTrailingSeparator = path.addTrailingSeparator(); String _string_2 = _addTrailingSeparator.toString(); org.eclipse.emf.common.util.URI _createPlatformResourceURI_1 = org.eclipse.emf.common.util.URI .createPlatformResourceURI(_string_2, true); String _string_3 = _createPlatformResourceURI_1.toString(); URL _uRL = new URL(_string_3); url = _uRL; result.add(url); } break; } } return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
From source file:de.loskutov.bco.ui.JdtUtils.java
License:Open Source License
/** * @param javaElement//from ww w . ja va2s.co m * @return absolute path of generated bytecode package for given element * @throws JavaModelException */ private static String getPackageOutputPath(IJavaElement javaElement) throws JavaModelException { String dir = ""; //$NON-NLS-1$ if (javaElement == null) { return dir; } IJavaProject project = javaElement.getJavaProject(); if (project == null) { return dir; } // default bytecode location IPath path = project.getOutputLocation(); IResource resource = javaElement.getUnderlyingResource(); if (resource == null) { return dir; } // resolve multiple output locations here if (project.exists() && project.getProject().isOpen()) { IClasspathEntry entries[] = project.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry classpathEntry = entries[i]; if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputPath = classpathEntry.getOutputLocation(); if (outputPath != null && classpathEntry.getPath().isPrefixOf(resource.getFullPath())) { path = outputPath; break; } } } } if (path == null) { // check the default location if not already included IPath def = project.getOutputLocation(); if (def != null && def.isPrefixOf(resource.getFullPath())) { path = def; } } if (path == null) { return dir; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (!project.getPath().equals(path)) { IFolder outputFolder = workspace.getRoot().getFolder(path); if (outputFolder != null) { // linked resources will be resolved here! IPath rawPath = outputFolder.getRawLocation(); if (rawPath != null) { path = rawPath; } } } else { path = project.getProject().getLocation(); } // here we should resolve path variables, // probably existing at first place of path IPathVariableManager pathManager = workspace.getPathVariableManager(); path = pathManager.resolvePath(path); if (path == null) { return dir; } if (isPackageRoot(project, resource)) { dir = path.toOSString(); } else { String packPath = EclipseUtils.getJavaPackageName(javaElement).replace(Signature.C_DOT, PACKAGE_SEPARATOR); dir = path.append(packPath).toOSString(); } return dir; }
From source file:de.loskutov.bco.ui.JdtUtils.java
License:Open Source License
private static void getClassURLs(IJavaProject javaProject, List<URL> urls) { IProject project = javaProject.getProject(); IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot(); IClasspathEntry[] paths = null;//from w ww. j a va 2s . c om IPath defaultOutputLocation = null; try { paths = javaProject.getResolvedClasspath(true); defaultOutputLocation = javaProject.getOutputLocation(); } catch (JavaModelException e) { // don't show message to user neither log it // BytecodeOutlinePlugin.log(e, IStatus.ERROR); } if (paths != null) { IPath projectPath = javaProject.getProject().getLocation(); for (int i = 0; i < paths.length; ++i) { IClasspathEntry cpEntry = paths[i]; IPath p = null; if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { // filter out source container - there are unused for class // search - add bytecode output location instead p = cpEntry.getOutputLocation(); if (p == null) { // default output used: p = defaultOutputLocation; } } else if (cpEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { String projName = cpEntry.getPath().toPortableString().substring(1); IProject proj = workspaceRoot.getProject(projName); IJavaProject projj = JavaCore.create(proj); getClassURLs(projj, urls); continue; } else { p = cpEntry.getPath(); } if (p == null) { continue; } if (!p.toFile().exists()) { // removeFirstSegments: remove project from relative path p = projectPath.append(p.removeFirstSegments(1)); if (!p.toFile().exists()) { continue; } } try { urls.add(p.toFile().toURI().toURL()); } catch (MalformedURLException e) { // don't show message to user BytecodeOutlinePlugin.log(e, IStatus.ERROR); } } } }