List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE
int CPE_SOURCE
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE.
Click Source Link
From source file:de.ovgu.featureide.core.builder.ComposerExtensionClass.java
License:Open Source License
/** * @param path The source path//w ww . ja va 2 s . c o m * @return A default source entry with the given path */ public IClasspathEntry getSourceEntry(String path) { return new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, new Path(path), new IPath[0], new IPath[0], null, null, null, false, null, false, new IClasspathAttribute[0]); }
From source file:de.ovgu.featureide.core.mpl.job.MPLRenameExternalJob.java
License:Open Source License
private static int getJavaBuildPathEntry(JavaProject javaProject) { try {/*from www .j av a2 s . c om*/ final IClasspathEntry[] classpathEntrys = javaProject.getRawClasspath(); for (int i = 0; i < classpathEntrys.length; ++i) { if (classpathEntrys[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { return i; } } } catch (JavaModelException e) { MPLPlugin.getDefault().logError(e); } return -1; }
From source file:de.ovgu.featureide.core.mpl.job.MPLRenameExternalJob.java
License:Open Source License
private static IPath setJavaBuildPath(JavaProject javaProject, IPath path, int index) { try {//from w ww. j ava2s. c o m final IClasspathEntry[] classpathEntrys = javaProject.getRawClasspath(); if (index >= 0) { final IClasspathEntry e = classpathEntrys[index]; if (!e.getPath().equals(path)) { final IPath formerSourcePath = e.getPath(); classpathEntrys[index] = new ClasspathEntry(e.getContentKind(), e.getEntryKind(), path, e.getInclusionPatterns(), e.getExclusionPatterns(), e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(), null, e.isExported(), e.getAccessRules(), e.combineAccessRules(), e.getExtraAttributes()); javaProject.setRawClasspath(classpathEntrys, null); return formerSourcePath; } } else { final IClasspathEntry[] newEntrys = new IClasspathEntry[classpathEntrys.length + 1]; System.arraycopy(classpathEntrys, 0, newEntrys, 0, classpathEntrys.length); newEntrys[newEntrys.length - 1] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, path, new IPath[0], new IPath[0], null, null, null, false, null, false, new IClasspathAttribute[0]); javaProject.setRawClasspath(newEntrys, null); } } catch (JavaModelException e) { MPLPlugin.getDefault().logError(e); } return null; }
From source file:de.ovgu.featureide.featurehouse.FeatureHouseComposer.java
License:Open Source License
/** * Sets the Java build path to the folder at the build folder, named like the current configuration. * @param buildPath The name of the current configuration *//* w w w .j a v a 2 s . co m*/ private void setJavaBuildPath(String buildPath) { try { JavaProject javaProject = new JavaProject(featureProject.getProject(), null); IClasspathEntry[] classpathEntrys = javaProject.getRawClasspath(); int i = 0; for (IClasspathEntry e : classpathEntrys) { if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = featureProject.getBuildFolder().getFolder(buildPath).getFullPath(); /** return if nothing has to be changed **/ if (e.getPath().equals(path)) { return; } /** change the actual source entry to the new build path **/ ClasspathEntry changedEntry = new ClasspathEntry(e.getContentKind(), e.getEntryKind(), path, e.getInclusionPatterns(), e.getExclusionPatterns(), e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(), null, e.isExported(), e.getAccessRules(), e.combineAccessRules(), e.getExtraAttributes()); classpathEntrys[i] = changedEntry; javaProject.setRawClasspath(classpathEntrys, null); return; } i++; } /** case: there is no source entry at the class path * add the source entry to the classpath **/ IFolder folder = featureProject.getBuildFolder().getFolder(buildPath); ClasspathEntry sourceEntry = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE, IClasspathEntry.CPE_SOURCE, folder.getFullPath(), new IPath[0], new IPath[0], null, null, null, false, null, false, new IClasspathAttribute[0]); IClasspathEntry[] newEntrys = new IClasspathEntry[classpathEntrys.length + 1]; System.arraycopy(classpathEntrys, 0, newEntrys, 0, classpathEntrys.length); newEntrys[newEntrys.length - 1] = sourceEntry; javaProject.setRawClasspath(newEntrys, null); } catch (JavaModelException e) { FeatureHouseCorePlugin.getDefault().logError(e); } }
From source file:de.ovgu.featureide.migration.impl.DefaultSPLMigrator.java
License:Open Source License
/** * @param project/*from w ww. j av a2 s.c o m*/ * @param destinationPath * @param classpathToMigrate */ private void migrateSourceFiles(IProject project, IPath destinationPath, IClasspathEntry[] classpathToMigrate) { IPath relativeDestinationPath = ((IPath) destinationPath.clone()).makeRelativeTo(newProject.getFullPath()); System.out.println( "migrate source destination: " + destinationPath + " relative: " + relativeDestinationPath); IFolder destination = newProject.getFolder(relativeDestinationPath); for (IClasspathEntry entry : classpathToMigrate) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { try { IPath relativeSourcePath = entry.getPath().makeRelativeTo(project.getFullPath()); IFolder source = project.getFolder(relativeSourcePath); SPLMigrationUtils.recursiveCopyFiles(source, destination); newProject.refreshLocal(IProject.DEPTH_INFINITE, null); } catch (CoreException e) { CorePlugin.getDefault().logError(e); e.printStackTrace(); } } } }
From source file:de.ovgu.featureide.ui.actions.generator.Generator.java
License:Open Source License
/** * Sets the classpath entries for the newly created project * @param p The new project//from www .j a va 2 s . c o m */ // TODO remove redundant calculations for each configuration // TODO copy settings private void setClassPath(IProject p) { JavaProject baseProject = new JavaProject(builder.featureProject.getProject(), null); JavaProject newProject = new JavaProject(p, null); try { IClasspathEntry[] entries = baseProject.getRawClasspath().clone(); for (int i = 0; i < entries.length; i++) { // set source entry to "src" IClasspathEntry e = entries[i]; if (entries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { entries[i] = new ClasspathEntry(e.getContentKind(), e.getEntryKind(), new Path("src"), e.getInclusionPatterns(), e.getExclusionPatterns(), e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(), null, e.isExported(), e.getAccessRules(), e.combineAccessRules(), e.getExtraAttributes()); } else if (e.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { // set the library entries and copy the libraries // which are direct at the old projects folder IPath path = e.getPath().removeFirstSegments(1); IProject project = builder.featureProject.getProject(); IFile file = project.getFile(path); if (!file.exists()) { path = e.getPath(); file = project.getFile(path); if (!file.exists()) { continue; } } createLibFolder(p.getFile(path).getParent()); file.copy(p.getFile(e.getPath().removeFirstSegments(1)).getFullPath(), true, null); entries[i] = new ClasspathEntry(e.getContentKind(), e.getEntryKind(), e.getPath().removeFirstSegments(1), e.getInclusionPatterns(), e.getExclusionPatterns(), e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(), null, e.isExported(), e.getAccessRules(), e.combineAccessRules(), e.getExtraAttributes()); } } newProject.setRawClasspath(entries, null); } catch (JavaModelException e) { UIPlugin.getDefault().logError(e); } catch (CoreException e) { UIPlugin.getDefault().logError(e); } }
From source file:de.ovgu.featureide.ui.wizards.ConversionPage.java
License:Open Source License
/** * Set the build path to the java projects build path *///from w w w. j a v a2 s. com private void setBuildPath() { try { if (p.hasNature(JAVA_NATURE)) { JavaProject javaProject = new JavaProject(p, null); for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { String path = entry.getPath().toOSString(); if (path.contains("\\")) path = path.substring(path.indexOf('\\') + 1); if (path.contains("\\")) path = path.substring(path.indexOf('\\') + 1); buildPath.setText(path); buildPath.setEnabled(false); buildLabel.setToolTipText(MESSAGE); return; } } } } catch (CoreException e) { UIPlugin.getDefault().logError(e); } }
From source file:de.ovgu.featureide.ui.wizards.FeatureCProjectPage.java
License:Open Source License
/** * Set the build path to the java projects build path *///from ww w . j ava2 s .c o m private void setBuildPath() { try { if (project.hasNature(JAVA_NATURE)) { JavaProject javaProject = new JavaProject(project, null); for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { String path = entry.getPath().toOSString(); String fileSeparator = System.getProperty("file.separator"); if (path.contains(fileSeparator)) path = path.substring(path.indexOf(fileSeparator) + 1); if (path.contains(fileSeparator)) path = path.substring(path.indexOf(fileSeparator) + 1); buildPath.setText(path); buildPath.setEnabled(false); buildLabel.setToolTipText(MESSAGE); return; } } } } catch (CoreException e) { UIPlugin.getDefault().logError(e); } }
From source file:de.tobject.findbugs.builder.FindBugsWorker.java
License:Open Source License
/** * @return map of all source folders to output folders, for current java * project, where both are represented by absolute IPath objects * * @throws CoreException/* www. j ava2s. c o m*/ */ private Map<IPath, IPath> createOutputLocations() throws CoreException { Map<IPath, IPath> srcToOutputMap = new HashMap<IPath, IPath>(); // get the default location => relative to wsp IPath defaultOutputLocation = ResourceUtils.relativeToAbsolute(javaProject.getOutputLocation()); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // path to the project without project name itself IClasspathEntry entries[] = javaProject.getResolvedClasspath(true); for (int i = 0; i < entries.length; i++) { IClasspathEntry classpathEntry = entries[i]; if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputLocation = ResourceUtils.getOutputLocation(classpathEntry, defaultOutputLocation); if (outputLocation == null) { continue; } IResource cpeResource = root.findMember(classpathEntry.getPath()); // patch from 2891041: do not analyze derived "source" folders // because they probably contain auto-generated classes if (cpeResource != null && cpeResource.isDerived()) { continue; } // TODO not clear if it is absolute in workspace or in global FS IPath srcLocation = ResourceUtils.relativeToAbsolute(classpathEntry.getPath()); if (srcLocation != null) { srcToOutputMap.put(srcLocation, outputLocation); } } } return srcToOutputMap; }
From source file:de.tobject.findbugs.builder.PDEClassPathGenerator.java
License:Open Source License
private static void resolveInWorkspace(IClasspathEntry classpathEntry, Set<String> classPath, Set<IProject> projectOnCp) { int entryKind = classpathEntry.getEntryKind(); switch (entryKind) { case IClasspathEntry.CPE_PROJECT: Set<String> cp = resolveProjectClassPath(classpathEntry.getPath(), projectOnCp); classPath.addAll(cp);/* ww w.ja v a 2 s.co m*/ break; case IClasspathEntry.CPE_VARIABLE: classpathEntry = JavaCore.getResolvedClasspathEntry(classpathEntry); if (classpathEntry == null) { return; } //$FALL-THROUGH$ case IClasspathEntry.CPE_LIBRARY: String lib = resolveLibrary(classpathEntry.getPath()); if (lib != null) { classPath.add(lib); } break; case IClasspathEntry.CPE_SOURCE: // ??? break; default: break; } }