List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_LIBRARY
int CPE_LIBRARY
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_LIBRARY.
Click Source Link
From source file:edu.brown.cs.bubbles.bedrock.BedrockProject.java
License:Open Source License
private void addPath(IvyXmlWriter xw, IJavaProject jp, IClasspathEntry ent, boolean nest) { IPath p = ent.getPath();//from w w w .j av a 2 s . co m IPath op = ent.getOutputLocation(); IPath sp = ent.getSourceAttachmentPath(); IProject ip = jp.getProject(); String jdp = null; boolean opt = false; IClasspathAttribute[] atts = ent.getExtraAttributes(); for (IClasspathAttribute att : atts) { if (att.getName().equals(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME)) jdp = att.getValue(); else if (att.getName().equals(IClasspathAttribute.OPTIONAL)) { String v = att.getValue(); if (v.equals("true")) opt = true; } } if (p == null && op == null) return; File f1 = null; if (p != null) { f1 = BedrockUtil.getFileForPath(p, ip); if (!f1.exists()) { BedrockPlugin.logD("Path file " + p + " not found as " + f1); // f1 = null; } } File f2 = null; if (op != null) { f2 = BedrockUtil.getFileForPath(op, ip); if (!f2.exists()) { BedrockPlugin.logD("Path file " + op + " not found"); f2 = null; } } File f3 = null; if (sp != null) { f3 = BedrockUtil.getFileForPath(sp, ip); if (!f3.exists()) { BedrockPlugin.logD("Path file " + sp + " not found"); f3 = null; } } if (f1 == null && f2 == null) return; // references to nested projects are handled in addClassPaths if (ent.getEntryKind() == IClasspathEntry.CPE_PROJECT) return; xw.begin("PATH"); xw.field("ID", ent.hashCode()); if (nest) xw.field("NESTED", "TRUE"); switch (ent.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: xw.field("TYPE", "SOURCE"); f3 = f1; f1 = null; break; case IClasspathEntry.CPE_PROJECT: xw.field("TYPE", "BINARY"); break; case IClasspathEntry.CPE_LIBRARY: xw.field("TYPE", "LIBRARY"); break; } if (ent.isExported()) xw.field("EXPORTED", true); if (opt) xw.field("OPTIONAL", true); if (f1 != null) xw.textElement("BINARY", f1.getAbsolutePath()); if (f2 != null) xw.textElement("OUTPUT", f2.getAbsolutePath()); if (f3 != null) xw.textElement("SOURCE", f3.getAbsolutePath()); if (jdp != null) xw.textElement("JAVADOC", jdp); IAccessRule[] rls = ent.getAccessRules(); for (IAccessRule ar : rls) { xw.begin("ACCESS"); xw.field("KIND", ar.getKind()); xw.field("PATTERN", ar.getPattern().toString()); xw.field("IGNOREIFBETTER", ar.ignoreIfBetter()); xw.end("ACCESS"); } xw.end("PATH"); }
From source file:edu.rice.cs.drjava.plugins.eclipse.repl.EclipseInteractionsModel.java
License:BSD License
private void _addProjectToClasspath(IJavaProject jProj, IJavaModel jModel, IWorkspaceRoot root) throws CoreException { // Get the project's location on disk IProject proj = jProj.getProject();//from w w w .j a va 2 s . c o m URI projRoot = proj.getDescription().getLocationURI(); // Note: getLocation returns null if the default location is used // (brilliant...) // Get the resolved classpath entries - this should filter out // all CPE_VARIABLE and CPE_CONTAINER entries. IClasspathEntry entries[] = jProj.getResolvedClasspath(true); // For each of the classpath entries... for (int j = 0; j < entries.length; j++) { IClasspathEntry entry = entries[j]; // Check what kind of entry it is... int kind = entry.getEntryKind(); // And get the appropriate path. IPath path; switch (kind) { case IClasspathEntry.CPE_LIBRARY: // The raw location of a JAR. path = entry.getPath(); //System.out.println("Adding library: " + path.toOSString()); addToClassPath(path.toOSString()); break; case IClasspathEntry.CPE_SOURCE: // The output location of source. // Need to append it to the user's workspace directory. path = entry.getOutputLocation(); if (path == null) { path = jProj.getOutputLocation(); //System.out.println(" output location from proj: " + path); } // At this point, the output location contains the project // name followed by the actual output folder name if (projRoot != null && (!projRoot.isAbsolute() || projRoot.getScheme().equals("file"))) { // We have a custom project location, so the project name // is not part of the *actual* output directory. We need // to remove the project name (first segment) and then // append the rest of the output location to projRoot. path = path.removeFirstSegments(1); path = new Path(projRoot.getPath()).append(path); } else { // A null projRoot means use the default location, which // *does* include the project name in the output directory. path = root.getLocation().append(path); } //System.out.println("Adding source: " + path.toOSString()); //addToClassPath(path.toOSString()); addBuildDirectoryClassPath(path.toOSString()); break; case IClasspathEntry.CPE_PROJECT: // In this case, just the project name is given. // We don't actually need to add anything to the classpath, // since the project is open and we will get its classpath // on another pass. break; default: // This should never happen. throw new RuntimeException("Unsupported classpath entry type."); } } }
From source file:edu.washington.cs.cupid.scripting.java.internal.UpdateClasspathJob.java
License:Open Source License
@Override public IStatus runInWorkspace(final IProgressMonitor monitor) { try {/*from w w w.j a v a 2 s . com*/ IJavaProject project = CupidScriptingPlugin.getDefault().getCupidJavaProject(); int classpathSize = project.getRawClasspath().length; monitor.beginTask("Update Cupid Classpath", classpathSize + 2); List<IClasspathEntry> updatedClasspath = Lists.newArrayList(); List<IClasspathEntry> updatedEntries = Lists.newArrayList(); List<String> allResolved = Lists.newArrayList(); for (IClasspathEntry entry : project.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { File file = entry.getPath().toFile(); if (file.exists()) { // the entry is valid allResolved.add(entry.getPath().toString()); updatedClasspath.add(entry); } else { // try to find bundle with same name IPath path = entry.getPath(); String filename = path.segment(path.segmentCount() - 1); String[] parts = filename.split("_"); if (parts.length == 2) { Bundle bundle = Platform.getBundle(parts[0]); if (bundle != null) { // we found a bundle with the same name IPath replacement = ClasspathUtil.bundlePath(bundle); IClasspathEntry newEntry = JavaCore.newLibraryEntry(replacement, null, null); updatedClasspath.add(newEntry); updatedEntries.add(newEntry); } else { CupidScriptingPlugin.getDefault() .logWarning("Can't find updated bundle for Cupid Project classpath entry: " + entry.getPath()); updatedClasspath.add(entry); } } else if (filename.startsWith("guava")) { CodeSource guavaSrc = Lists.class.getProtectionDomain().getCodeSource(); IClasspathEntry newEntry = JavaCore .newLibraryEntry(ClasspathUtil.urlToPath(guavaSrc.getLocation()), null, null); updatedClasspath.add(newEntry); updatedEntries.add(newEntry); } else { // TODO handle other internal JARs besides Guava CupidScriptingPlugin.getDefault() .logWarning("Can't find updated library for Cupid Project classpath entry: " + entry.getPath()); // we don't know how to find the name updatedClasspath.add(entry); } } } else { // don't try to handle variables / projects updatedClasspath.add(entry); allResolved.add(entry.getPath().toString()); } monitor.worked(1); } CupidScriptingPlugin.getDefault().logInformation("Found " + allResolved.size() + " valid Cupid classpath entries (see log for details)" + System.getProperty("line.separator") + Joiner.on(System.getProperty("line.separator")).join(allResolved)); if (!updatedEntries.isEmpty()) { // perform update project.setRawClasspath(updatedClasspath.toArray(new IClasspathEntry[] {}), new SubProgressMonitor(monitor, 1)); for (IClasspathEntry entry : updatedEntries) { CupidScriptingPlugin.getDefault() .logInformation("Updated Cupid classpath entry " + entry.getPath()); } } else { CupidScriptingPlugin.getDefault().logInformation("Cupid Project classpath is up-to-date"); } return Status.OK_STATUS; } catch (Exception ex) { return new Status(IStatus.ERROR, CupidScriptingPlugin.PLUGIN_ID, "Error updating Cupid scripting classpath", ex); } finally { monitor.done(); } }
From source file:es.optsicom.res.client.util.ProjectDependenciesResolver.java
License:Eclipse Public License
private void calculateDependencies(IClasspathEntry[] cpe, IProject project) throws DependenciesResolverException { try {// ww w . j a v a2 s . c o m IWorkspace workspace = project.getWorkspace(); IPath workspacePath = workspace.getRoot().getLocation(); String nombreWorkspace = workspacePath.toString(); IJavaProject jp = JavaCore.create(project); if (!dependencies.contains(project.getLocation().toString())) { // Aadimos la carpeta bin classpathFiles.add(workspacePath.append(jp.getOutputLocation()).toFile()); classpath.add(jp.getOutputLocation().toString()); } for (IClasspathEntry cpEntry : cpe) { String path = cpEntry.getPath().toString(); String dependency = nombreWorkspace.concat(path); if (!dependencies.contains(dependency)) { RESClientPlugin.log("Adding dependency: " + dependency); dependencies.add(dependency); if (cpEntry.getOutputLocation() != null) { RESClientPlugin.log("Binarios: " + cpEntry.getOutputLocation().toString()); classpath.add(cpEntry.getOutputLocation().makeRelativeTo(workspacePath).toString()); classpathFiles.add(cpEntry.getOutputLocation().toFile()); } int tipo = cpEntry.getEntryKind(); //Si la dependencia es de una libreria( if (tipo == IClasspathEntry.CPE_LIBRARY) { String dep = cpEntry.getPath().makeRelativeTo(workspacePath).toString(); //mgarcia: Optsicom res Evolution if (new File(workspacePath.toFile(), cpEntry.getPath().toOSString()).exists()) { classpathFiles.add(new File(workspacePath.toFile(), cpEntry.getPath().toOSString())); //Aadimos las dependencias a las properties RESClientPlugin.log("Adding library: " + dep); classpath.add(cpEntry.getPath().toString()); } else { throw new DependenciesResolverException(); } } else if (tipo == IClasspathEntry.CPE_PROJECT) { // File[] files = new File(dependency).listFiles(); // for (File f : files){ // lista.add(f); // String dep = f.getPath(); // RESClientPlugin.log("Adding dependency: " + dep); // dependencies.add(dep); // } IProject p = workspace.getRoot().getProject(cpEntry.getPath().lastSegment()); IJavaProject projectDependency = JavaCore.create(p); IClasspathEntry[] cp = projectDependency.getRawClasspath(); classpathFiles.add(workspacePath.append(projectDependency.getOutputLocation()).toFile()); classpath.add(projectDependency.getOutputLocation().toString()); RESClientPlugin.log("Populating files from: " + p.getName()); calculateDependencies(cp, p); } else if (tipo == IClasspathEntry.CPE_SOURCE) { File f = new File(dependency); classpathFiles.add(f); RESClientPlugin.log("Adding source: " + dependency); } else if (tipo == IClasspathEntry.CPE_VARIABLE) { IClasspathEntry[] clpe = new IClasspathEntry[1]; clpe[0] = JavaCore.getResolvedClasspathEntry(cpEntry); if (clpe[0] != null) { RESClientPlugin.log("Populating files from: " + clpe[0].getPath().toOSString()); calculateDependencies(clpe, project); } } else if (tipo == IClasspathEntry.CPE_CONTAINER) { if (cpEntry.getPath().toOSString().contains("JRE_CONTAINER") || cpEntry.getPath().toOSString().contains("requiredPlugins")) { continue; } IClasspathContainer cc = JavaCore.getClasspathContainer(cpEntry.getPath(), jp); IClasspathEntry[] entradas = cc.getClasspathEntries(); RESClientPlugin.log("Populating files from: " + cc.getPath().toOSString()); calculateDependencies(entradas, project); } } } } catch (JavaModelException e) { RESClientPlugin.log(e); } for (String path : classpath) { RESClientPlugin.log("Classpath: " + path); } for (File file : classpathFiles) { RESClientPlugin.log("Classpath file: " + file.getAbsolutePath()); } }
From source file:fede.workspace.eclipse.composition.copy.exporter.JavaClassRefExporter.java
License:Apache License
protected Map<IPath, FolderExportedContent> findLocations(FolderExportedContent folderContent, String exporterType) throws JavaModelException, CoreException { IJavaProject javaProject = JavaProjectManager.getJavaProject(getItem()); Map<IPath, FolderExportedContent> outputLocations = new HashMap<IPath, FolderExportedContent>(); IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); if (exporterType.equals(JAVA_REF_EXPORTER_TYPE)) { for (IClasspathEntry entry : rawClasspath) { if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) continue; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputPath = entry.getOutputLocation(); if (outputPath == null) outputPath = javaProject.getOutputLocation(); outputLocations.put(getRelativePath(outputPath), folderContent); } else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IPath outputPath = entry.getPath(); if (outputPath != null) outputLocations.put(getRelativePath(outputPath), folderContent); }/*from w w w .j a v a 2 s. c om*/ } } else { for (IClasspathEntry entry : rawClasspath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputPath = entry.getPath(); if (outputPath != null) outputLocations.put(getRelativePath(outputPath), folderContent); } else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IPath outputPath = entry.getSourceAttachmentPath(); if (outputPath != null) outputLocations.put(getRelativePath(outputPath), folderContent); } } } return outputLocations; }
From source file:fr.imag.adele.cadse.cadseg.menu.ExportBundlePagesAction.java
License:Apache License
@Override public void doFinish(UIPlatform uiPlatform, Object monitor) throws Exception { super.doFinish(uiPlatform, monitor); IProgressMonitor pmo = (IProgressMonitor) monitor; try {//from w ww . j a v a 2 s. c o m EclipsePluginContentManger project = (EclipsePluginContentManger) cadsedef.getContentItem(); pmo.beginTask("export cadse " + cadsedef.getName(), 1); String qname = cadsedef.getQualifiedName(); String qname_version = ""; String version = ""; IJavaProject jp = project.getMainMappingContent(IJavaProject.class); IProject eclipseProject = project.getProject(); IPath eclipseProjectPath = eclipseProject.getFullPath(); // jp.getProject().build(kind, pmo) IPath defaultOutputLocation = jp.getOutputLocation(); IPath manifestPath = new Path(JarFile.MANIFEST_NAME); HashSet<IPath> excludePath = new HashSet<IPath>(); excludePath.add(eclipseProjectPath.append(manifestPath)); excludePath.add(eclipseProjectPath.append(".project")); excludePath.add(eclipseProjectPath.append(".classpath")); excludePath.add(eclipseProjectPath.append("run-cadse-" + cadsedef.getName() + ".launch")); excludePath.add(eclipseProjectPath.append(".melusine.ser")); excludePath.add(eclipseProjectPath.append(".melusine.xml")); Manifest mf = new Manifest(eclipseProject.getFile(manifestPath).getContents()); File pf = new File(file, qname + ".jar"); File sourceDir = new File(file, qname + ".Source"); if (tstamp) { Date d = new Date(System.currentTimeMillis()); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm"); String timeStamp = "v" + formatter.format(d); version = mf.getMainAttributes().getValue(OsgiManifest.BUNDLE_VERSION); String[] partVersion = version.split("\\."); if (partVersion.length == 4) { version = version + "-" + timeStamp; } else { version = version + "." + timeStamp; } mf.getMainAttributes().putValue(OsgiManifest.BUNDLE_VERSION, version); pf = new File(file, qname + "_" + version + ".jar"); qname_version = qname + "_" + version; sourceDir = new File(file, qname + ".Source_" + version); } JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(pf), mf); HashMap<IFile, IPath> files = new HashMap<IFile, IPath>(); IWorkspaceRoot eclipseRoot = eclipseProject.getWorkspace().getRoot(); IContainer classesFolder = (IContainer) eclipseRoot.findMember(defaultOutputLocation); addFolder(files, excludePath, classesFolder, Path.EMPTY); IClasspathEntry[] classpaths = jp.getRawClasspath(); for (IClasspathEntry entry : classpaths) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (entry.getOutputLocation() != null) { classesFolder = (IContainer) eclipseRoot.findMember(entry.getOutputLocation()); addFolder(files, excludePath, classesFolder, Path.EMPTY); } IPath sourcePath = entry.getPath(); excludePath.add(sourcePath); continue; } if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { } } addFolder(files, excludePath, eclipseProject, Path.EMPTY); pmo.beginTask("export cadse " + cadsedef.getName(), files.size()); Set<IFile> keySet = new TreeSet<IFile>(new Comparator<IFile>() { public int compare(IFile o1, IFile o2) { return o1.getFullPath().toPortableString().compareTo(o2.getFullPath().toPortableString()); } }); keySet.addAll(files.keySet()); for (IFile f : keySet) { IPath entryPath = files.get(f); pmo.worked(1); try { ZipUtil.addEntryZip(outputStream, f.getContents(), entryPath.toPortableString(), f.getLocalTimeStamp()); } catch (Throwable e) { // TODO Auto-generated catch block e.printStackTrace(); } } outputStream.close(); if (deleteOld) { File[] childrenFiles = file.listFiles(); if (childrenFiles != null) { for (File f : childrenFiles) { if (f.equals(pf)) { continue; } String fileName = f.getName(); if (!fileName.startsWith(qname)) { continue; } FileUtil.deleteDir(f); } } } if (exportSource && tstamp) { sourceDir.mkdir(); File srcDir = new File(sourceDir, "src"); srcDir.mkdir(); File mfDir = new File(sourceDir, "META-INF"); mfDir.mkdir(); File modelDir = new File(srcDir, qname_version); modelDir.mkdir(); FileUtil.setFile(new File(sourceDir, "plugin.xml"), "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<?eclipse version=\"3.0\"?>\n" + "<plugin>\n" + "<extension point=\"org.eclipse.pde.core.source\">\n" + "<location path=\"src\"/>\n" + "</extension>\n" + "</plugin>\n"); String vendor_info = CadseDefinitionManager.getVendorNameAttribute(cadsedef); FileUtil.setFile(new File(mfDir, "MANIFEST.MF"), "Manifest-Version: 1.0\n" + "Bundle-ManifestVersion: 2\n" + "Bundle-SymbolicName: " + qname + ".Source;singleton:=true\n" + "Bundle-Version: " + version + "\n" + "Bundle-Localization: plugin\n" + "Bundle-Vendor: " + vendor_info + "\n" + "Bundle-Name: " + qname + "\n"); excludePath.clear(); files.clear(); classesFolder = (IContainer) eclipseRoot.findMember(defaultOutputLocation); excludePath.add(classesFolder.getFullPath()); for (IClasspathEntry entry : classpaths) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (entry.getOutputLocation() != null) { classesFolder = (IContainer) eclipseRoot.findMember(entry.getOutputLocation()); addFolder(files, excludePath, classesFolder, Path.EMPTY); } IPath sourcePath = entry.getPath(); excludePath.add(sourcePath); ZipUtil.zipDirectory(eclipseRoot.findMember(sourcePath).getLocation().toFile(), new File(modelDir, "src.zip"), null); continue; } } addFolder(files, excludePath, eclipseProject, Path.EMPTY); keySet = files.keySet(); for (IFile f : keySet) { IPath entryPath = files.get(f); try { FileUtil.copy(f.getLocation().toFile(), new File(modelDir, entryPath.toOSString()), false); } catch (Throwable e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { } }
From source file:fr.obeo.acceleo.tools.classloaders.AcceleoGenClassLoader.java
License:Open Source License
private static void computeURLs(IProject project, List URLs) { IFolder binFolder = Resources.getOutputFolder(project); if (binFolder != null) { String location = binFolder.getLocation().toString(); if (location.startsWith("/")) { //$NON-NLS-1$ location = '/' + location; }//from w w w. ja v a 2 s .c o m try { URLs.add(new URL("file:/" + location + '/')); //$NON-NLS-1$ } catch (MalformedURLException e) { // continue } } IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] entries; try { entries = javaProject.getResolvedClasspath(true); } catch (JavaModelException e1) { entries = new IClasspathEntry[] {}; } for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IProject reference = ResourcesPlugin.getWorkspace().getRoot() .getProject(entry.getPath().toString()); if (reference.exists()) { AcceleoGenClassLoader.computeURLs(reference, URLs); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { try { IFile reference = ResourcesPlugin.getWorkspace().getRoot().getFile(entry.getPath()); if (reference.exists()) { URL url = (URL) AcceleoGenClassLoader.cacheURL.get(reference.getLocation().toFile()); if (url == null) { url = reference.getLocation().toFile().toURL(); AcceleoGenClassLoader.cacheURL.put(reference.getLocation().toFile(), url); } URLs.add(url); } else { URL url = (URL) AcceleoGenClassLoader.cacheURL.get(entry.getPath().toFile()); if (url == null) { url = entry.getPath().toFile().toURL(); AcceleoGenClassLoader.cacheURL.put(entry.getPath().toFile(), url); } URLs.add(url); } } catch (MalformedURLException e) { // continue } } else { try { URL url = (URL) AcceleoGenClassLoader.cacheURL.get(entry.getPath().toFile()); if (url == null) { url = entry.getPath().toFile().toURL(); AcceleoGenClassLoader.cacheURL.put(entry.getPath().toFile(), url); } URLs.add(url); } catch (MalformedURLException e) { // continue } } } }
From source file:gov.redhawk.ide.codegen.jet.java.template.StartJavaShTemplate.java
License:Open Source License
/** * {@inheritDoc}//www.j a v a2 s .c o m */ public String generate(Object argument) { final StringBuffer stringBuffer = new StringBuffer(); JavaTemplateParameter template = (JavaTemplateParameter) argument; ImplementationSettings implSettings = template.getImplSettings(); Implementation impl = template.getImpl(); SoftPkg softPkg = (SoftPkg) impl.eContainer(); IResource resource = ModelUtil.getResource(implSettings); IProject project = resource.getProject(); IJavaProject javaProject = JavaCore.create(project); String implName = gov.redhawk.ide.codegen.util.CodegenFileHelper.safeGetImplementationName(impl, implSettings); String jarPrefix = gov.redhawk.ide.codegen.util.CodegenFileHelper.getPreferredFilePrefix(softPkg, implSettings); String pkg = template.getPackage(); String mainClass = gov.redhawk.ide.codegen.jet.java.JavaGeneratorProperties.getMainClass(impl, implSettings); String projDir = "/" + project.getName() + "/" + implSettings.getOutputDir(); String libs = ""; String vars = ""; try { for (final IClasspathEntry path : javaProject.getRawClasspath()) { if (path.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { final String lib = path.getPath().toString(); libs += lib.replaceAll(projDir, "\\$myDir") + ":"; } else if (path.getEntryKind() == IClasspathEntry.CPE_VARIABLE) { vars += "$" + path.getPath().toString() + ":"; } } } catch (JavaModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } stringBuffer.append(TEXT_1); stringBuffer.append(libs); stringBuffer.append(TEXT_2); stringBuffer.append(vars); stringBuffer.append(TEXT_3); stringBuffer.append(jarPrefix); stringBuffer.append(TEXT_4); stringBuffer.append(mainClass); stringBuffer.append(TEXT_5); stringBuffer.append(libs); stringBuffer.append(TEXT_6); stringBuffer.append(vars); stringBuffer.append(TEXT_7); stringBuffer.append(jarPrefix); stringBuffer.append(TEXT_8); stringBuffer.append(mainClass); stringBuffer.append(TEXT_9); stringBuffer.append(TEXT_10); return stringBuffer.toString(); }
From source file:in.software.analytics.parichayana.core.internal.builder.ParichayanaBuilder.java
License:Open Source License
private IProject[] getRequiredProjects(boolean includeBinaryPrerequisites) { JavaProject javaProject = (JavaProject) JavaCore.create(this.project); IWorkspaceRoot workspaceRoot = this.project.getWorkspace().getRoot(); if (javaProject == null || workspaceRoot == null) { return ZERO_PROJECT; }/*from w w w .ja v a 2 s.com*/ List<IProject> projects = new ArrayList<IProject>(); ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager(); try { IClasspathEntry[] entries = javaProject.getExpandedClasspath(); for (int i = 0, l = entries.length; i < l; i++) { IClasspathEntry entry = entries[i]; IPath path = entry.getPath(); IProject p = null; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_PROJECT: p = workspaceRoot.getProject(path.lastSegment()); // missing projects are considered too if (((ClasspathEntry) entry).isOptional() && !JavaProject.hasJavaNature(p)) // except if entry is optional p = null; break; case IClasspathEntry.CPE_LIBRARY: if (includeBinaryPrerequisites && path.segmentCount() > 0) { // some binary resources on the class path can come from projects that are not included in the project references IResource resource = workspaceRoot.findMember(path.segment(0)); if (resource instanceof IProject) { p = (IProject) resource; } else { resource = externalFoldersManager.getFolder(path); if (resource != null) p = resource.getProject(); } } } if (p != null && !projects.contains(p)) projects.add(p); } } catch (JavaModelException e) { return ZERO_PROJECT; } IProject[] result = new IProject[projects.size()]; projects.toArray(result); return result; }
From source file:info.evanchik.eclipse.felix.FelixLaunchConfiguration.java
License:Open Source License
/** * Gets the path to the specified bundle in the following manner:<br> * <br>//from w ww . java2 s . c o m * <ol> * <li>If the bundle is found in the Plug-in Registry and is not a workspace * resource, return the path to the bundle</li> * <li>If the bundle is in the Plug-in Registry but is a workspace resource, * return the path to the path to the output location that contains the * package specified ({@code project/output folder})</li> * <li>If the bundle is not found in the Plug-in Registry then look for it * in the OSGi platform</li> * </ol> * * @param bundleName * the symbolic name of the bundle * @param packageName * the name of the package used to locate the output folder * @return a fully qualified path to the requested bundle or null if it does * not exist * @throws CoreException */ private static String getBundlePath(String bundleName, String packageName) throws CoreException { final IPluginModelBase model = PluginRegistry.findModel(bundleName); if (model != null) { final IResource resource = model.getUnderlyingResource(); if (!isWorkspaceModel(model)) { return model.getInstallLocation(); } final IProject project = resource.getProject(); if (project.hasNature(JavaCore.NATURE_ID)) { final IJavaProject jProject = JavaCore.create(project); final IClasspathEntry[] entries = jProject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { final int kind = entries[i].getEntryKind(); if (kind == IClasspathEntry.CPE_SOURCE || kind == IClasspathEntry.CPE_LIBRARY) { final IPackageFragmentRoot[] roots = jProject.findPackageFragmentRoots(entries[i]); for (int j = 0; j < roots.length; j++) { if (roots[j].getPackageFragment(packageName).exists()) { // if source folder, find the output folder if (kind == IClasspathEntry.CPE_SOURCE) { IPath path = entries[i].getOutputLocation(); if (path == null) { path = jProject.getOutputLocation(); } path = path.removeFirstSegments(1); return project.getLocation().append(path).toOSString(); } // else if is a library jar, then get the // location of the jar itself final IResource jar = roots[j].getResource(); if (jar != null) { return jar.getLocation().toOSString(); } } } } } } } final Bundle bundle = Platform.getBundle(bundleName); if (bundle != null) { try { URL url = FileLocator.resolve(bundle.getEntry("/")); //$NON-NLS-1$ url = FileLocator.toFileURL(url); String path = url.getFile(); if (path.startsWith("file:")) { //$NON-NLS-1$ path = path.substring(5); } path = new File(path).getAbsolutePath(); if (path.endsWith("!")) { //$NON-NLS-1$ path = path.substring(0, path.length() - 1); } return path; } catch (IOException e) { } } return null; }