List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_VARIABLE
int CPE_VARIABLE
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_VARIABLE.
Click Source Link
From source file:es.optsicom.res.client.util.ProjectDependenciesResolver.java
License:Eclipse Public License
private void calculateDependencies(IClasspathEntry[] cpe, IProject project) throws DependenciesResolverException { try {//from w ww. ja va2 s . c om 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:gov.redhawk.ide.codegen.jet.java.template.StartJavaShTemplate.java
License:Open Source License
/** * {@inheritDoc}//from w ww . j a va 2s.c om */ 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:icy.icy4eclipse.core.IcyProject.java
License:Open Source License
void fixBuildpath() { try {/*from w ww .j a v a2 s . co m*/ IClasspathEntry[] entries = javaProject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; String path = entry.getPath().toOSString(); if ((entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) && (path.startsWith(Icy4EclipsePlugin.getIcyHomeDir()))) { String npath = path.substring(Icy4EclipsePlugin.getIcyHomeDir().length()); IPath ipath = new Path(ICY4ECLIPSE_HOME_VARIABLE + npath); entries[i] = JavaCore.newVariableEntry(ipath, null, null); Icy4EclipsePlugin.logInfo("fixBuildpath : " + path + " -> " + ipath.toOSString()); } } javaProject.setRawClasspath(entries, null); } catch (JavaModelException e) { Icy4EclipsePlugin.logException(e); } }
From source file:io.sarl.eclipse.util.JavaClasspathParser.java
License:Apache License
/** * Decodes one XML element with the XML stream. * * @param element/* w w w. j a va2s. c om*/ * - the considered element * @param projectName * - the name of project containing the .classpath file * @param projectRootAbsoluteFullPath * - he path to project containing the .classpath file * @param unknownElements * - map of unknown elements * @return the set of CLasspath ENtries extracted from the considered element */ @SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity" }) public static IClasspathEntry elementDecode(Element element, String projectName, IPath projectRootAbsoluteFullPath, Map<IPath, UnknownXmlElements> unknownElements) { final IPath projectPath = projectRootAbsoluteFullPath; final NamedNodeMap attributes = element.getAttributes(); final NodeList children = element.getChildNodes(); final boolean[] foundChildren = new boolean[children.getLength()]; final String kindAttr = removeAttribute(ClasspathEntry.TAG_KIND, attributes); final String pathAttr = removeAttribute(ClasspathEntry.TAG_PATH, attributes); // ensure path is absolute IPath path = new Path(pathAttr); final int kind = kindFromString(kindAttr); if (kind != IClasspathEntry.CPE_VARIABLE && kind != IClasspathEntry.CPE_CONTAINER && !path.isAbsolute()) { if (!(path.segmentCount() > 0 && path.segment(0).equals(ClasspathEntry.DOT_DOT))) { path = projectPath.append(path); } } // source attachment info (optional) IPath sourceAttachmentPath = element.hasAttribute(ClasspathEntry.TAG_SOURCEPATH) ? new Path(removeAttribute(ClasspathEntry.TAG_SOURCEPATH, attributes)) : null; if (kind != IClasspathEntry.CPE_VARIABLE && sourceAttachmentPath != null && !sourceAttachmentPath.isAbsolute()) { sourceAttachmentPath = projectPath.append(sourceAttachmentPath); } final IPath sourceAttachmentRootPath = element.hasAttribute(ClasspathEntry.TAG_ROOTPATH) ? new Path(removeAttribute(ClasspathEntry.TAG_ROOTPATH, attributes)) : null; // exported flag (optional) final boolean isExported = removeAttribute(ClasspathEntry.TAG_EXPORTED, attributes).equals("true"); //$NON-NLS-1$ // inclusion patterns (optional) IPath[] inclusionPatterns = decodePatterns(attributes, ClasspathEntry.TAG_INCLUDING); if (inclusionPatterns == null) { inclusionPatterns = ClasspathEntry.INCLUDE_ALL; } // exclusion patterns (optional) IPath[] exclusionPatterns = decodePatterns(attributes, ClasspathEntry.TAG_EXCLUDING); if (exclusionPatterns == null) { exclusionPatterns = ClasspathEntry.EXCLUDE_NONE; } // access rules (optional) NodeList attributeList = getChildAttributes(ClasspathEntry.TAG_ACCESS_RULES, children, foundChildren); IAccessRule[] accessRules = decodeAccessRules(attributeList); // backward compatibility if (accessRules == null) { accessRules = getAccessRules(inclusionPatterns, exclusionPatterns); } // combine access rules (optional) final boolean combineAccessRestrictions = !removeAttribute(ClasspathEntry.TAG_COMBINE_ACCESS_RULES, attributes).equals("false"); //$NON-NLS-1$ // extra attributes (optional) attributeList = getChildAttributes(ClasspathEntry.TAG_ATTRIBUTES, children, foundChildren); final IClasspathAttribute[] extraAttributes = decodeExtraAttributes(attributeList); // custom output location final IPath outputLocation = element.hasAttribute(ClasspathEntry.TAG_OUTPUT) ? projectPath.append(removeAttribute(ClasspathEntry.TAG_OUTPUT, attributes)) : null; String[] unknownAttributes = null; ArrayList<String> unknownChildren = null; if (unknownElements != null) { // unknown attributes final int unknownAttributeLength = attributes.getLength(); if (unknownAttributeLength != 0) { unknownAttributes = new String[unknownAttributeLength * 2]; for (int i = 0; i < unknownAttributeLength; i++) { final Node attribute = attributes.item(i); unknownAttributes[i * 2] = attribute.getNodeName(); unknownAttributes[i * 2 + 1] = attribute.getNodeValue(); } } // unknown children for (int i = 0, length = foundChildren.length; i < length; i++) { if (!foundChildren[i]) { final Node node = children.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } if (unknownChildren == null) { unknownChildren = new ArrayList<>(); } final StringBuffer buffer = new StringBuffer(); decodeUnknownNode(node, buffer); unknownChildren.add(buffer.toString()); } } } // recreate the CP entry IClasspathEntry entry = null; switch (kind) { case IClasspathEntry.CPE_PROJECT: /* * IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_PROJECT, path, ClasspathEntry.INCLUDE_ALL, // inclusion patterns * ClasspathEntry.EXCLUDE_NONE, // exclusion patterns null, // source attachment null, // source attachment root null, // specific output * folder */ entry = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_PROJECT, path, ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, null, null, isExported, accessRules, combineAccessRestrictions, extraAttributes); break; case IClasspathEntry.CPE_LIBRARY: entry = JavaCore.newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, accessRules, extraAttributes, isExported); break; case IClasspathEntry.CPE_SOURCE: // must be an entry in this project or specify another project final String projSegment = path.segment(0); if (projSegment != null && projSegment.equals(projectName)) { // this project entry = JavaCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, outputLocation, extraAttributes); } else { if (path.segmentCount() == 1) { // another project entry = JavaCore.newProjectEntry(path, accessRules, combineAccessRestrictions, extraAttributes, isExported); } else { // an invalid source folder entry = JavaCore.newSourceEntry(path, inclusionPatterns, exclusionPatterns, outputLocation, extraAttributes); } } break; case IClasspathEntry.CPE_VARIABLE: entry = JavaCore.newVariableEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, accessRules, extraAttributes, isExported); break; case IClasspathEntry.CPE_CONTAINER: entry = JavaCore.newContainerEntry(path, accessRules, extraAttributes, isExported); break; case ClasspathEntry.K_OUTPUT: if (!path.isAbsolute()) { return null; } /* * ClasspathEntry.EXCLUDE_NONE, null, // source attachment null, // source attachment root null, // custom output location false, null, // * no access rules false, // no accessible files to combine */ entry = new ClasspathEntry(ClasspathEntry.K_OUTPUT, IClasspathEntry.CPE_LIBRARY, path, ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, null, null, false, null, false, ClasspathEntry.NO_EXTRA_ATTRIBUTES); break; default: throw new AssertionFailedException(Messages.bind(Messages.classpath_unknownKind, kindAttr)); } if (unknownAttributes != null || unknownChildren != null) { final UnknownXmlElements unknownXmlElements = new UnknownXmlElements(); unknownXmlElements.attributes = unknownAttributes; unknownXmlElements.children = unknownChildren; if (unknownElements != null) { unknownElements.put(path, unknownXmlElements); } } return entry; }
From source file:io.sarl.eclipse.util.JavaClasspathParser.java
License:Apache License
/** * Returns the kind of a <code>PackageFragmentRoot</code> from its <code>String</code> form. * * @param kindStr//from w w w. j av a 2 s. c om * - string to test * @return the integer identifier of the type of the specified string: CPE_PROJECT, CPE_VARIABLE, CPE_CONTAINER, etc. */ @SuppressWarnings("checkstyle:equalsavoidnull") private static int kindFromString(String kindStr) { if (kindStr.equalsIgnoreCase("prj")) { //$NON-NLS-1$ return IClasspathEntry.CPE_PROJECT; } if (kindStr.equalsIgnoreCase("var")) { //$NON-NLS-1$ return IClasspathEntry.CPE_VARIABLE; } if (kindStr.equalsIgnoreCase("con")) { //$NON-NLS-1$ return IClasspathEntry.CPE_CONTAINER; } if (kindStr.equalsIgnoreCase("src")) { //$NON-NLS-1$ return IClasspathEntry.CPE_SOURCE; } if (kindStr.equalsIgnoreCase("lib")) { //$NON-NLS-1$ return IClasspathEntry.CPE_LIBRARY; } if (kindStr.equalsIgnoreCase("output")) { //$NON-NLS-1$ return ClasspathEntry.K_OUTPUT; } return -1; }
From source file:net.kbserve.pyjdt.properties.models.CPEAbstractContainer.java
License:Open Source License
/** * Update the list of children to include the ICPEType contains the giveb IClasspathEntry * /*ww w . j a v a2 s .c o m*/ * @param child * the child * @param project * the project * @return the iCPE type */ public synchronized ICPEType updateChild(IClasspathEntry child, IProject project) { String stringPath = makeStringPath(child.getPath()); ICPEType icp = getChild(stringPath); if (icp == null) { switch (child.getEntryKind()) { case (IClasspathEntry.CPE_CONTAINER): icp = new CPEContainer(); break; case (IClasspathEntry.CPE_LIBRARY): icp = new CPELibrary(); break; case (IClasspathEntry.CPE_PROJECT): icp = new CPEProject(); break; case (IClasspathEntry.CPE_SOURCE): icp = new CPESource(); break; case (IClasspathEntry.CPE_VARIABLE): icp = new CPEVariable(); break; default: throw new UnsupportedOperationException( "Unsupported IClasspathEntry.getEntryKind() = '" + child.getEntryKind() + "' on " + child); } children.add(icp); icp.setPath(stringPath); icp.setParent(this.getPath()); } return icp; }
From source file:net.rim.ejde.internal.packaging.PackagingManager.java
License:Open Source License
static private void getCompileImportsRecusively(IClasspathEntry[] entries, IJavaProject jProject, Vector<ImportedJar> imports, boolean isMainProject) throws CoreException { if (imports == null) { imports = new Vector<ImportedJar>(); }// ww w.j av a 2 s . c om // Workspace imports; if there aren't any specified, default to // using the runtime libraries. IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // String jarPathString; try { BlackBerryProperties properties = null; boolean needAddBBJar = false; IPath jarPath = null; ImportedJar importedJar = null; for (IClasspathEntry entry : entries) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: { // libraries IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), jProject.getJavaProject()); if (container == null) { continue; } IVMInstall containerVM; if (!(container instanceof JREContainer)) { // We need to verify the type of the container because the path of Maven container only has one // segment and JavaRuntime.getVMInstall(IPath) return the default VM install if the entry path has one // segment. containerVM = null; } else { containerVM = JavaRuntime.getVMInstall(entry.getPath()); } try { if (containerVM != null) { if (containerVM.getVMInstallType().getId().equals(BlackBerryVMInstallType.VM_ID)) { if (isMainProject) { // Add jars to a list IClasspathEntry[] classpathEntries = container.getClasspathEntries(); if (classpathEntries != null && classpathEntries.length > 0) { getCompileImportsRecusively(classpathEntries, jProject, imports, false); } } } else { if (!jProject.getProject().hasNature(BlackBerryProjectCoreNature.NATURE_ID)) { needAddBBJar = true; continue; } } } else { // Add jars to a list IClasspathEntry[] classpathEntries = container.getClasspathEntries(); if (classpathEntries != null && classpathEntries.length > 0) { getCompileImportsRecusively(classpathEntries, jProject, imports, false); } } } catch (CoreException e) { _log.error(e.getMessage()); continue; } break; } case IClasspathEntry.CPE_LIBRARY: { // imported jars jarPath = PackageUtils.getAbsoluteEntryPath(entry); // the jar path can be null if the jar file does not exist if (jarPath == null) { throw new CoreException(StatusFactory.createErrorStatus( NLS.bind(Messages.PackagingManager_Entry_Not_Found_MSG, entry.getPath()))); } if (jarPath.lastSegment().equals(IConstants.RIM_API_JAR) && needAddBBJar) { needAddBBJar = false; } importedJar = null; if (PackagingUtils.getPackagExportedJar()) { if (entry.isExported()) { if (isMainProject) { // if the exported jar is not in the main project but a dependent project, the classes it // contains are packaged into the dependent project jar. We don't add it to classpath. importedJar = new ImportedJar(jarPath.toOSString(), true, getJarFileType(jarPath.toFile())); } } else { importedJar = new ImportedJar(jarPath.toOSString(), false, getJarFileType(jarPath.toFile())); } } else { importedJar = new ImportedJar(jarPath.toOSString(), false, getJarFileType(jarPath.toFile())); } if (importedJar != null && !existingJar(imports, importedJar)) { imports.add(importedJar); } break; } case IClasspathEntry.CPE_PROJECT: { // dependency projects IProject project = workspaceRoot.getProject(entry.getPath().toString()); IJavaProject javaProject = JavaCore.create(project); try { if (project.hasNature(BlackBerryProjectCoreNature.NATURE_ID)) { properties = ContextManager.PLUGIN.getBBProperties(javaProject.getProject().getName(), false); if (properties == null) { _log.error("BlackBerry properties is null"); break; } } else { properties = BlackBerryPropertiesFactory.createBlackBerryProperties(javaProject); } } catch (CoreException e) { _log.error(e.getMessage()); continue; } if (PackagingManager.getProjectTypeID(properties._application.getType()) == Project.LIBRARY) { IPath absoluteJarPath = PackagingUtils .getAbsoluteStandardOutputFilePath(new BlackBerryProject(javaProject, properties)); File jarFile = new File( absoluteJarPath.toOSString() + IConstants.DOT_MARK + IConstants.JAR_EXTENSION); importedJar = new ImportedJar(jarFile.getAbsolutePath(), false, getJarFileType(jarFile)); if (!existingJar(imports, importedJar)) { imports.add(importedJar); } IClasspathEntry[] subEntries = javaProject.getRawClasspath(); if (subEntries != null && subEntries.length > 0) { getCompileImportsRecusively(subEntries, javaProject, imports, false); } } break; } case IClasspathEntry.CPE_VARIABLE: { // variables String e = entry.getPath().toString(); int index = e.indexOf('/'); if (index == -1) { index = e.indexOf('\\'); } String variable = e; IPath cpvar = JavaCore.getClasspathVariable(variable); if (cpvar == null) { String msg = NLS.bind(Messages.PackagingManager_Variable_Not_Defined_MSG, variable); throw new CoreException(StatusFactory.createErrorStatus(msg)); } if (cpvar.lastSegment().equals(IConstants.RIM_API_JAR) && needAddBBJar) { needAddBBJar = false; } // TODO RAPC does not support a class folder. We may support it later on if (cpvar.lastSegment().endsWith("." + IConstants.JAR_EXTENSION)) { importedJar = new ImportedJar(cpvar.toOSString(), false, getJarFileType(cpvar.toFile())); if (!existingJar(imports, importedJar)) { imports.add(importedJar); } } break; } } } if (needAddBBJar && isMainProject) { // insert the default BB jre lib if needed IVMInstall bbVM = VMUtils.getDefaultBBVM(); if (bbVM != null) { LibraryLocation[] libLocations = bbVM.getLibraryLocations(); if (libLocations != null) { for (LibraryLocation location : libLocations) { importedJar = new ImportedJar(location.getSystemLibraryPath().toOSString(), false, getJarFileType(location.getSystemLibraryPath().toFile())); if (!existingJar(imports, importedJar)) { imports.add(importedJar); } } } } } } catch (JavaModelException e) { _log.error(e.getMessage()); } }
From source file:net.rim.ejde.internal.sourcelookup.RIMSourcePathProvider.java
License:Open Source License
/** * Computes and returns the default unresolved runtime classpath for the given project. * * @return runtime classpath entries//ww w.j a v a2 s .c om * @exception CoreException * if unable to compute the runtime classpath * @see IRuntimeClasspathEntry */ public static IRuntimeClasspathEntry[] computeUnresolvedRuntimeClasspath(IJavaProject project) throws CoreException { IClasspathEntry[] entries = project.getRawClasspath(); List<IRuntimeClasspathEntry> classpathEntries = new ArrayList<IRuntimeClasspathEntry>(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project); if (container != null) { switch (container.getKind()) { case IClasspathContainer.K_APPLICATION: // don't look at application entries break; case IClasspathContainer.K_DEFAULT_SYSTEM: classpathEntries.add(JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), IRuntimeClasspathEntry.STANDARD_CLASSES, project)); break; case IClasspathContainer.K_SYSTEM: classpathEntries.add(JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES, project)); break; } } break; case IClasspathEntry.CPE_VARIABLE: if (JavaRuntime.JRELIB_VARIABLE.equals(entry.getPath().segment(0))) { IRuntimeClasspathEntry jre = JavaRuntime.newVariableRuntimeClasspathEntry(entry.getPath()); jre.setClasspathProperty(IRuntimeClasspathEntry.STANDARD_CLASSES); classpathEntries.add(jre); } break; default: break; } } classpathEntries.add(JavaRuntime.newDefaultProjectClasspathEntry(project)); return classpathEntries.toArray(new IRuntimeClasspathEntry[classpathEntries.size()]); }
From source file:net.sf.eclipse.tomcat.TomcatLauncherPlugin.java
License:Open Source License
/** * Remove TOMCAT_HOME variable from Tomcat projects build path * (Eclipse 3 will not compile Tomcat projects without this fix) *//* w w w .ja v a 2s. c om*/ private void fixTomcatHomeBug() { if (this.getPreferenceStore().getString("fixTomcatHomeBug").equals("")) { this.getPreferenceStore().setValue("fixTomcatHomeBug", "fixed"); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject[] projects = root.getProjects(); try { for (IProject project : projects) { if (project.hasNature(NATURE_ID)) { List cp = new ArrayList(projects.length - 1); IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] classpath = javaProject.getRawClasspath(); cp.addAll(Arrays.asList(classpath)); for (IClasspathEntry element : classpath) { if (element.getEntryKind() == IClasspathEntry.CPE_VARIABLE) { if (element.getPath().equals(TomcatLauncherPlugin.getDefault().getTomcatIPath())) { cp.remove(element); } } } javaProject.setRawClasspath((IClasspathEntry[]) cp.toArray(new IClasspathEntry[cp.size()]), null); } } } catch (Exception e) { log(e); } } }
From source file:net.sf.eclipse.tomcat.TomcatProject.java
License:Open Source License
/** * Add servlet.jar and jasper.jar to project classpath */// w w w. jav a 2 s . c o m public void addTomcatJarToProjectClasspath() throws CoreException { TomcatBootstrap tb = TomcatLauncherPlugin.getDefault().getTomcatBootstrap(); IClasspathEntry[] entries = javaProject.getRawClasspath(); List cp = new ArrayList(entries.length + 1); for (IClasspathEntry entrie : entries) { IClasspathEntry entry = entrie; if (!((entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE) && (entry.getPath().toOSString() .startsWith(TomcatLauncherPlugin.getDefault().getTomcatIPath().toOSString())))) { cp.add(entry); } } cp.addAll(tb.getTomcatJars()); javaProject.setRawClasspath((IClasspathEntry[]) cp.toArray(new IClasspathEntry[cp.size()]), null); }