本文整理汇总了Java中org.eclipse.jdt.core.IJavaProject.setRawClasspath方法的典型用法代码示例。如果您正苦于以下问题:Java IJavaProject.setRawClasspath方法的具体用法?Java IJavaProject.setRawClasspath怎么用?Java IJavaProject.setRawClasspath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IJavaProject
的用法示例。
在下文中一共展示了IJavaProject.setRawClasspath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addJunit4Libraries
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Add JUnit libraries to the passed project
*
* @param project
* @throws JavaModelException
*/
private static void addJunit4Libraries(IProject project) throws JavaModelException {
IClasspathEntry entry = JavaCore.newContainerEntry(JUnitCore.JUNIT4_CONTAINER_PATH);
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
boolean junitFound = false;
String s = entry.getPath().toString();
for (int i = 0; i < entries.length; i++) {
if (entries[i].getPath().toString().indexOf(s) != -1) {
junitFound = true;
break;
}
}
if (!junitFound) {
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
newEntries[entries.length] = entry;
javaProject.setRawClasspath(newEntries, null);
}
}
示例2: removeFromProject
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static void removeFromProject(IJavaProject javaProject)
{
try
{
Set<IClasspathEntry> entries = new LinkedHashSet<>();
entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
if( entries.remove(JavaCore.newContainerEntry(JPFClasspathPlugin.CONTAINER_PATH)) )
{
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
}
}
catch( JavaModelException e )
{
JPFClasspathLog.logError(e);
}
}
示例3: addGW4EClassPathContainer
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Add GraphWalker libraries to the passed project
*
* @param project
* @throws JavaModelException
*/
public static void addGW4EClassPathContainer(IProject project) throws JavaModelException {
if (hasGW4EClassPathContainer(project)) {
return;
}
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
Path lcp = new Path(GW4ELibrariesContainer.ID);
IClasspathEntry libEntry = JavaCore.newContainerEntry(lcp, true);
newEntries[entries.length] = JavaCore.newContainerEntry(libEntry.getPath(), true);
javaProject.setRawClasspath(newEntries, null);
addJunit4Libraries(project);
}
示例4: removeFolderFromClasspath
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Remove the passed folder from ClassPath
*
* @param project
* @param folderPath
* @param monitor
* @throws JavaModelException
*/
public static void removeFolderFromClasspath(IProject project, String folderPath, IProgressMonitor monitor)
throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
List<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>();
IPath folder = project.getFolder(folderPath).getFullPath();
for (int i = 0; i < entries.length; i++) {
if (!entries[i].getPath().equals(folder)) {
newEntries.add(entries[i]);
}
}
entries = new IClasspathEntry[newEntries.size()];
newEntries.toArray(entries);
javaProject.setRawClasspath(entries, monitor);
}
示例5: addToProject
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static void addToProject(IJavaProject javaProject)
{
try
{
Set<IClasspathEntry> entries = new LinkedHashSet<>();
entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
entries.add(JavaCore.newContainerEntry(JPFClasspathPlugin.CONTAINER_PATH));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
}
catch( JavaModelException e )
{
JPFClasspathLog.logError(e);
}
}
示例6: ensureExcludedPath
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Manage source folders exclusion
*
* @param project
* @param rootSrcEntry
* @param relative
* @return
* @throws JavaModelException
*/
private static IClasspathEntry ensureExcludedPath(IProject project, IClasspathEntry rootSrcEntry,
String relative) throws JavaModelException {
if (rootSrcEntry == null)
return rootSrcEntry;
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
IPath[] excluded = rootSrcEntry.getExclusionPatterns();
boolean entryFound = false;
for (int i = 0; i < excluded.length; i++) {
if (excluded[i].toString().equalsIgnoreCase(relative)) {
entryFound = true;
break;
}
}
if (!entryFound) {
IPath rootSrcPath = javaProject.getPath().append("src");
IPath[] newEntries = new IPath[excluded.length + 1];
System.arraycopy(excluded, 0, newEntries, 0, excluded.length);
newEntries[excluded.length] = new Path(relative);
rootSrcEntry = JavaCore.newSourceEntry(rootSrcPath, newEntries);
entries = javaProject.getRawClasspath();
List<IClasspathEntry> temp = new ArrayList<IClasspathEntry>();
temp.add(rootSrcEntry);
for (int i = 0; i < entries.length; i++) {
if (!(entries[i].getPath().equals(rootSrcPath))) {
temp.add(entries[i]);
}
}
IClasspathEntry[] array = new IClasspathEntry[temp.size()];
temp.toArray(array);
javaProject.setRawClasspath(array, null);
}
return rootSrcEntry;
}
示例7: ensureFolderInClasspath
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Make sure the passed folder is in the classpath
*
* @param project
* @param folderPath
* @param monitor
* @return
* @throws JavaModelException
*/
public static IClasspathEntry ensureFolderInClasspath(IProject project, String folderPath,
IProgressMonitor monitor) throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
if (folderPath.startsWith("src")) {
handleFolderExclusion(project, folderPath);
}
IClasspathEntry[] entries = javaProject.getRawClasspath();
boolean classpathentryFound = false;
IPath folder = project.getFolder(folderPath).getFullPath();
for (int i = 0; i < entries.length; i++) {
if (entries[i].getPath().equals(folder)) {
classpathentryFound = true;
return entries[i];
}
}
if (!classpathentryFound) {
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
IPath srcPath = javaProject.getPath().append(folderPath);
IClasspathEntry srcEntry = JavaCore.newSourceEntry(srcPath, null);
newEntries[entries.length] = JavaCore.newSourceEntry(srcEntry.getPath());
javaProject.setRawClasspath(newEntries, monitor);
return srcEntry;
}
return null;
}
示例8: removeGW4EClassPathContainer
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Remove GW4E ClassPath Container
*
* @param project
* @param monitor
* @throws JavaModelException
*/
public static void removeGW4EClassPathContainer(IProject project, IProgressMonitor monitor)
throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
List<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>();
for (int i = 0; i < entries.length; i++) {
if (!GW4ELibrariesContainer.isMe(entries[i])) {
newEntries.add(entries[i]);
}
}
entries = new IClasspathEntry[newEntries.size()];
newEntries.toArray(entries);
javaProject.setRawClasspath(entries, monitor);
}
示例9: addGWClassPathEntry
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static void addGWClassPathEntry(IJavaProject javaProject) throws JavaModelException {
IClasspathEntry[] entries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
Path lcp = new Path(GW4ELibrariesContainer.ID);
IClasspathEntry libEntry = JavaCore.newContainerEntry(lcp, true);
newEntries[entries.length] = JavaCore.newContainerEntry(libEntry.getPath(), true);
javaProject.setRawClasspath(newEntries, new NullProgressMonitor());
}
示例10: createProject
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static IJavaProject createProject(String name) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(name);
if (!project.exists()) {
project.create(new NullProgressMonitor());
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
if (!project.isOpen()) {
project.open(new NullProgressMonitor());
}
IFolder binFolder = project.getFolder("bin");
if (!binFolder.exists()) {
createFolder(binFolder, false, true, new NullProgressMonitor());
}
IPath outputLocation = binFolder.getFullPath();
addNatureToProject(project, JavaCore.NATURE_ID, new NullProgressMonitor());
IJavaProject jproject = JavaCore.create(project);
jproject.setOutputLocation(outputLocation, new NullProgressMonitor());
IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();
jproject.setRawClasspath(entries, new NullProgressMonitor());
return jproject;
}
示例11: addToClasspath
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static void addToClasspath(IJavaProject jproject, IClasspathEntry cpe) throws JavaModelException {
IClasspathEntry[] oldEntries = jproject.getRawClasspath();
for (int i = 0; i < oldEntries.length; i++) {
if (oldEntries[i].equals(cpe)) {
return;
}
}
int nEntries = oldEntries.length;
IClasspathEntry[] newEntries = new IClasspathEntry[nEntries + 1];
System.arraycopy(oldEntries, 0, newEntries, 0, nEntries);
newEntries[nEntries] = cpe;
jproject.setRawClasspath(newEntries, new NullProgressMonitor());
}
示例12: addEntry
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Add a new entry to the existing java project
* you can use JavaCore factory to create the entry itself
* ex : JavaCore.newProjectEntry(ecoreIFile.getProject().getFullPath())
* If the entry is already there, the method will do nothing.
*/
public static void addEntry(IProject project, IClasspathEntry newEntry, IProgressMonitor monitor) throws CoreException{
IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
ArrayList<IClasspathEntry> newClassPathArrayList = new ArrayList<IClasspathEntry>();
IClasspathEntry[] previousentries = javaProject.getRawClasspath();
for(IClasspathEntry previousentry : previousentries){
newClassPathArrayList.add(previousentry);
}
if(!newClassPathArrayList.contains(newEntry)){
newClassPathArrayList.add(newEntry);
IClasspathEntry[] newClassPath = new IClasspathEntry[newClassPathArrayList.size()];
javaProject.setRawClasspath(newClassPathArrayList.toArray(newClassPath), monitor);
}
}
示例13: addClassPathEntry
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
private void addClassPathEntry(IPath tempSrcFolder) throws JavaModelException {
IJavaProject javaProject=JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject());
oldClasspathEntry=javaProject.getRawClasspath();
IClasspathEntry[] newClasspathEntry=new IClasspathEntry[oldClasspathEntry.length+1];
for(int index=0;index<newClasspathEntry.length-1;index++){
if(oldClasspathEntry[index].getPath().equals(tempSrcFolder))
return ;
newClasspathEntry[index]=javaProject.getRawClasspath()[index];
}
newClasspathEntry[newClasspathEntry.length-1]=JavaCore.newSourceEntry(tempSrcFolder);
javaProject.setRawClasspath(newClasspathEntry, new NullProgressMonitor());
}
示例14: createJavaProject
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
private IJavaProject createJavaProject(String name) throws CoreException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
if (project.exists())
project.delete(true, null);
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project);
javaProject.setRawClasspath(new IClasspathEntry[] { JavaCore.newVariableEntry(new Path("JRE_LIB"), null, null) }, null);
return javaProject;
}
示例15: createProject
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* This method creates a new java project based on the user inputs, captured in WizardInput object.
* The new project is created in the current workspace.
* @param wizardInput
* @return IJavaProject
* @throws CoreException
* @throws IOException
**/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(wizardInput.getProjectName());
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project);
IFolder binFolder = project.getFolder("bin");
binFolder.create(false, true, null);
javaProject.setOutputLocation(binFolder.getFullPath(), null);
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation element : locations) {
entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
}
InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
IFile jarFile = project.getFile("soot-trunk.jar");
jarFile.create(is, false, null);
IPath path = jarFile.getFullPath();
entries.add(JavaCore.newLibraryEntry(path, null, null));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
IFolder sourceFolder = project.getFolder("src");
sourceFolder.create(false, true, null);
IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
javaProject.setRawClasspath(newEntries, null);
String filepath = sourceFolder.getLocation().toOSString();
File file = new File(filepath);
wizardInput.setFile(file);
try {
CodeGenerator.generateSource(wizardInput);
} catch (JClassAlreadyExistsException e) {
e.printStackTrace();
}
sourceFolder.refreshLocal(1, null);
javaProject.open(null);
return javaProject;
}