List of usage examples for org.eclipse.jdt.internal.core JavaProject JavaProject
public JavaProject(IProject project, JavaElement parent)
From source file:de.ovgu.featureide.ahead.actions.FeatureHouseToAHEADConversion.java
License:Open Source License
/** * Sets the java build path to the build folder of the given feature project. * @param featureProject//from w ww . j ava 2 s. co m */ private void setJavaBuildPath(IFeatureProject featureProject) { try { JavaProject javaProject = new JavaProject(featureProject.getProject(), null); IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); for (int i = 0; i < classpathEntries.length; i++) { /** change the actual source entry **/ if (classpathEntries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { classpathEntries[i] = setSourceEntry(classpathEntries[i]); javaProject.setRawClasspath(classpathEntries, null); return; } } /** case: no source entry **/ IClasspathEntry[] newEntries = new IClasspathEntry[classpathEntries.length + 1]; System.arraycopy(classpathEntries, 0, newEntries, 0, classpathEntries.length); newEntries[newEntries.length - 1] = getSourceEntry(); javaProject.setRawClasspath(classpathEntries, null); } catch (JavaModelException e) { AheadCorePlugin.getDefault().logError(e); } }
From source file:de.ovgu.featureide.aspectj.AspectJComposer.java
License:Open Source License
/** * Set the unselected aspects to be excluded from build * @param project/* w ww. jav a 2 s. co m*/ */ private void setBuildpaths(IProject project) { String buildPath = null; if (featureProject == null || featureProject.getBuildPath() == null) { buildPath = IFeatureProject.DEFAULT_SOURCE_PATH; } else { buildPath = featureProject.getBuildPath(); } try { JavaProject javaProject = new JavaProject(project, null); IClasspathEntry[] oldEntries = javaProject.getRawClasspath(); /** check if entries already exist **/ for (int i = 0; i < oldEntries.length; i++) { if (oldEntries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { /** correct the source entry **/ oldEntries[i] = setSourceEntry(oldEntries[i]); javaProject.setRawClasspath(oldEntries, null); return; } } /** add the new entry **/ IClasspathEntry[] entries = new IClasspathEntry[oldEntries.length + 1]; System.arraycopy(oldEntries, 0, entries, 0, oldEntries.length); entries[oldEntries.length] = setSourceEntry(getSourceEntry(buildPath)); javaProject.setRawClasspath(entries, null); } catch (JavaModelException e) { CorePlugin.getDefault().logError(e); } }
From source file:de.ovgu.featureide.aspectj.AspectJComposer.java
License:Open Source License
private void addClasspathFile(IProject project, String buildPath) { if (buildPath == null) { if (featureProject == null || featureProject.getBuildPath() == null) { buildPath = IFeatureProject.DEFAULT_SOURCE_PATH; } else {/* w w w. j av a2s .c o m*/ buildPath = featureProject.getBuildPath(); } } try { JavaProject javaProject = new JavaProject(project, null); IClasspathEntry[] oldEntries = javaProject.getRawClasspath(); boolean sourceAdded = false; boolean containerAdded = false; boolean ajContainerAdded = false; /** check if entries already exist **/ for (int i = 0; i < oldEntries.length; i++) { if (!sourceAdded && oldEntries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { /** correct the source entry **/ oldEntries[i] = getSourceEntry(buildPath); sourceAdded = true; } else if ((!containerAdded || !ajContainerAdded) && oldEntries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) { /** check the container entries **/ if (oldEntries[i].getPath().equals(JRE_CONTAINER)) { containerAdded = true; } if (oldEntries[i].getPath().equals(ASPECTJRT_CONTAINER)) { ajContainerAdded = true; } } } /** case: no new entries **/ if (sourceAdded && containerAdded && ajContainerAdded) { javaProject.setRawClasspath(oldEntries, null); return; } /** add the new entries **/ IClasspathEntry[] entries = new IClasspathEntry[(sourceAdded ? 0 : 1) + (containerAdded ? 0 : 1) + (containerAdded ? 0 : 1) + oldEntries.length]; System.arraycopy(oldEntries, 0, entries, 0, oldEntries.length); if (!sourceAdded) { entries[oldEntries.length] = getSourceEntry(buildPath); } if (!containerAdded) { int position = (sourceAdded ? 0 : 1) + oldEntries.length; entries[position] = getContainerEntry(); } if (!ajContainerAdded) { int position = (sourceAdded ? 0 : 1) + (containerAdded ? 0 : 1) + oldEntries.length; entries[position] = getAJContainerEntry(); } javaProject.setRawClasspath(entries, null); } catch (JavaModelException e) { CorePlugin.getDefault().logError(e); } }
From source file:de.ovgu.featureide.core.builder.ComposerExtensionClass.java
License:Open Source License
private void addClasspathFile(IProject project, String buildPath) { try {/*ww w.j a va 2 s . c om*/ JavaProject javaProject = new JavaProject(project, null); IClasspathEntry[] oldEntries = javaProject.getRawClasspath(); boolean sourceAdded = false; boolean containerAdded = false; /** check if entries already exist **/ for (int i = 0; i < oldEntries.length; i++) { if (!sourceAdded && oldEntries[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { /** correct the source entry **/ // XXX the source entry should be equivalent to the build path, // but e.g. at FeatureHouse the real build path is src/config -> Builder problems // -> is it necessary to correct the path? if (oldEntries[i].getPath().toString().equals("/" + project.getName())) { /** necessary after creating a new FeatureIDE project **/ oldEntries[i] = setSourceEntry(buildPath, oldEntries[i]); } /** find source entry **/ sourceAdded = true; } else if (!containerAdded && oldEntries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) { /** check the container entries **/ if (oldEntries[i].getPath().equals(JRE_CONTAINER)) { containerAdded = true; } } } /** case: no new entries **/ if (sourceAdded && containerAdded) { javaProject.setRawClasspath(oldEntries, null); return; } /** add the new entries **/ IClasspathEntry[] entries = new IClasspathEntry[(sourceAdded ? 0 : 1) + (containerAdded ? 0 : 1) + oldEntries.length]; System.arraycopy(oldEntries, 0, entries, 0, oldEntries.length); if (!sourceAdded) { entries[oldEntries.length] = getSourceEntry(buildPath); } if (!containerAdded) { int position = (sourceAdded ? 0 : 1) + oldEntries.length; entries[position] = getContainerEntry(); } javaProject.setRawClasspath(entries, null); } catch (JavaModelException e) { CorePlugin.getDefault().logError(e); } }
From source file:de.ovgu.featureide.core.mpl.job.CreateFujiSignaturesJob.java
License:Open Source License
private static String getClassPaths(IFeatureProject featureProject) { String classpath = ""; String sep = System.getProperty("path.separator"); try {/*from ww w . j av a2s . c o m*/ JavaProject proj = new JavaProject(featureProject.getProject(), null); IJavaElement[] elements = proj.getChildren(); for (IJavaElement e : elements) { String path = e.getPath().toOSString(); if (path.contains(":")) { classpath += sep + path; continue; } IResource resource = e.getResource(); if (resource != null && "jar".equals(resource.getFileExtension())) { classpath += sep + resource.getRawLocation().toOSString(); } } } catch (JavaModelException e) { } return classpath.length() > 0 ? classpath.substring(1) : classpath; }
From source file:de.ovgu.featureide.core.mpl.job.MPLRenameExternalJob.java
License:Open Source License
protected MPLRenameExternalJob(Arguments arguments) { super("Renaming Packages", arguments); setPriority(BUILD);//www .j a v a 2 s. c om javaProject = new JavaProject(arguments.externalProject, null); }
From source file:de.ovgu.featureide.core.mpl.job.MPLRenameExternalJob.java
License:Open Source License
public static void setJavaBuildPath(IProject project, IPath path) { final JavaProject javaProject = new JavaProject(project, null); setJavaBuildPath(javaProject, path, getJavaBuildPathEntry(javaProject)); }
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 *//*from w ww. j a v a 2s . c om*/ 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
/** * /*from w w w .java2 s . c o m*/ * @param project * @param destinationPath * @throws JavaModelException */ private void migrateClassPathDependentContent(IProject project, IPath destinationPath) throws JavaModelException { JavaProject javaProjectToMigrate = new JavaProject(project, null); JavaProject newJavaProject = new JavaProject(newProject, null); assert (javaProjectToMigrate != null && newJavaProject != null) : JAVA_PROJECTS_COULD_NOT_BE_CREATED; IClasspathEntry[] classpathToMigrate = javaProjectToMigrate.getRawClasspath(); List<IClasspathEntry> newClassPath = new ArrayList<IClasspathEntry>(); newClassPath.addAll(Arrays.asList(newJavaProject.getRawClasspath())); assert classpathToMigrate != null : CLASSPATH_OF_PROJECT_TO_MIGRATE_IS_NULL; migrateLibraryAndContainerEntries(newJavaProject, classpathToMigrate, newClassPath); migrateSourceFiles(project, destinationPath, classpathToMigrate); migrateProjectNatures(project); }
From source file:de.ovgu.featureide.ui.actions.generator.ConfigurationBuilder.java
License:Open Source License
/** * Sets the java classPath for compiling. *///from w w w . ja va2s . c om private void setClassPath() { String sep = System.getProperty("path.separator"); try { JavaProject proj = new JavaProject(featureProject.getProject(), null); IJavaElement[] elements = proj.getChildren(); for (IJavaElement e : elements) { String path = e.getPath().toOSString(); if (path.contains(":")) { classpath += sep + path; continue; } IResource resource = e.getResource(); if (resource != null && "jar".equals(resource.getFileExtension())) { classpath += sep + resource.getRawLocation().toOSString(); } } } catch (JavaModelException e) { } classpath = classpath.length() > 0 ? classpath.substring(1) : classpath; }