当前位置: 首页>>代码示例>>Java>>正文


Java IClasspathEntry类代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IClasspathEntry的典型用法代码示例。如果您正苦于以下问题:Java IClasspathEntry类的具体用法?Java IClasspathEntry怎么用?Java IClasspathEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IClasspathEntry类属于org.eclipse.jdt.core包,在下文中一共展示了IClasspathEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addJunit4Libraries

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的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);
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:ClasspathManager.java

示例2: addJarFilesNotInClasspath

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
private void addJarFilesNotInClasspath(IProgressMonitor monitor, IProject project, IJavaProject javaProject) throws CoreException
{
	 addMembersOfFolderToClasspath("/lib", monitor, javaProject);
	 addMembersOfFolderToClasspath("/web/webroot/WEB-INF/lib", monitor, javaProject);
	 // check if this is a backoffice extension
	 IFolder backofficeFolder = javaProject.getProject().getFolder("/resources/backoffice");
	 if (backofficeFolder != null && backofficeFolder.exists())
	 {
		 IResource backofficeJar = backofficeFolder.findMember(javaProject.getProject().getName() + "_bof.jar");
		 if (backofficeJar != null && backofficeJar.exists())
		 {
			 if (!isClasspathEntryForJar(javaProject, backofficeJar))
			 {
				 Activator.log("Adding library [" + backofficeJar.getFullPath() + "] to classpath for project [" + javaProject.getProject().getName() + "]");
				 FixProjectsUtils.addToClassPath(backofficeJar, IClasspathEntry.CPE_LIBRARY, javaProject, monitor);
			 }
		 }
	 }
	 
	 // add db drivers for platform/lib/dbdriver directory
	 if (project.getName().equalsIgnoreCase("platform"))
	 {
		 addMembersOfFolderToClasspath("/lib/dbdriver", monitor, javaProject);
	 }
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:26,代码来源:Importer.java

示例3: computePluginEntries

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
private IClasspathEntry[] computePluginEntries()
{
	List<IClasspathEntry> entries = new ArrayList<>();
	IResolvedPlugin resolvedPlugin = JPFPluginModelManager.instance().getResolvedPlugin(fModel);
	if( resolvedPlugin == null )
	{
		return new IClasspathEntry[0];
	}
	Set<IModel> seen = new HashSet<>();
	IResolvedPlugin hostPlugin = resolvedPlugin.getHostPlugin();
	if( hostPlugin != null )
	{
		addImports(hostPlugin, entries, true, true, false, seen);
	}
	addImports(resolvedPlugin, entries, true, false, true, seen);
	return entries.toArray(new IClasspathEntry[entries.size()]);
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:JPFClasspathContainer.java

示例4: removeFromProject

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的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);
	}

}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:JPFClasspathContainer.java

示例5: createClasspathEntries

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
@Override
public List<IClasspathEntry> createClasspathEntries()
{
	IPath srcJar = null;
	if( underlyingResource.getFileExtension().equals("jar") )
	{
		String name = underlyingResource.getName();
		IFile srcJarFile = underlyingResource.getProject().getFile(
			"lib-src/" + name.substring(0, name.length() - 4) + "-sources.jar");
		if( srcJarFile.exists() )
		{
			srcJar = srcJarFile.getFullPath();
		}
	}
	return Arrays.asList(JavaCore.newLibraryEntry(underlyingResource.getFullPath(), srcJar, null));
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:JarPluginModelImpl.java

示例6: getProjectClassPath

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
public static void getProjectClassPath(IJavaProject project, List<File> dst) throws Exception {
	IRuntimeClasspathEntry [] rentries = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
	for (IRuntimeClasspathEntry entry : rentries) {
		switch (entry.getType()) {
		case IClasspathEntry.CPE_SOURCE: 
			break;
		case IClasspathEntry.CPE_PROJECT:
			break;
		case IClasspathEntry.CPE_LIBRARY:
			break;
		case IClasspathEntry.CPE_VARIABLE:
			// JRE like entries
			IRuntimeClasspathEntry [] variableEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			break;
		case IClasspathEntry.CPE_CONTAINER:
			IRuntimeClasspathEntry [] containerEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			for (IRuntimeClasspathEntry containerentry : containerEntries) {
				dst.add(new File (containerentry.getLocation()));
			}
			break;
		default:
			throw new Exception("unsupported classpath entry "+entry);
		}
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:TestResourceGeneration.java

示例7: addGW4EClassPathContainer

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的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);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:22,代码来源:ClasspathManager.java

示例8: removeFolderFromClasspath

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的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);

}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:25,代码来源:ClasspathManager.java

示例9: getFilteredSourceFolders

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
/**
 * @param projectName
 * @return the direct child folders of the project
 * @throws CoreException
 */
public static List<String> getFilteredSourceFolders(String projectName, String[] excludes) throws CoreException {
	List<String> ret = new ArrayList<String>();
	IJavaProject javaProject = (IJavaProject) JavaCore.create(getProject(projectName));
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	for (int i = 0; i < entries.length; i++) {
		IClasspathEntry entry = entries[i];
		if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
			IPath path = entry.getPath().makeRelativeTo(new Path(projectName));
			boolean isExcluded = false;
			for (int j = 0; j < excludes.length; j++) {

				if (excludes[j].equalsIgnoreCase(path.toString())) {
					isExcluded = true;
					break;
				}
			}
			if (!isExcluded) {
				String p = path.toString();
				ret.add(p);
			}
		}
	}

	return ret;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:31,代码来源:ResourceManager.java

示例10: copyExternalLibAndAddToClassPath

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
private void copyExternalLibAndAddToClassPath(String source,IFolder destinationFolder, List<IClasspathEntry> entries) throws CoreException{
	File sourceFileLocation = new File(source);
	File[] listFiles = sourceFileLocation.listFiles();
	if(listFiles != null){
		for(File sourceFile : listFiles){
			IFile destinationFile = destinationFolder.getFile(sourceFile.getName());
			try(InputStream fileInputStream = new FileInputStream(sourceFile)) {
				if(!destinationFile.exists()){ //used while importing a project
					destinationFile.create(fileInputStream, true, null);
				}
				entries.add(JavaCore.newLibraryEntry(new Path(destinationFile.getLocation().toOSString()), null, null));
			} catch (IOException | CoreException exception) {
				logger.debug("Copy external library files operation failed", exception);
				throw new CoreException(new MultiStatus(Activator.PLUGIN_ID, 101, "Copy external library files operation failed", exception));
			}
		}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:19,代码来源:ProjectStructureCreator.java

示例11: setClasspath

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
public static void setClasspath(IClasspathEntry[] classpath, IJavaProject javaProject, IProgressMonitor monitor) throws JavaModelException
{
	// backup .classpath
	File classPathFileBak = javaProject.getProject().getFile(".classpath.bak").getLocation().toFile();
	if (!classPathFileBak.exists())
	{
		File classPathFile = javaProject.getProject().getFile(".classpath").getLocation().toFile();
		try {
			Files.copy(Paths.get(classPathFile.getAbsolutePath()), Paths.get(classPathFileBak.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING);
		}
		catch (IOException e) {
			// can't back up file but we should continue anyway
			Activator.log("Failed to backup classfile [" + classPathFile.getAbsolutePath() + "]");
		}
	}
	javaProject.setRawClasspath(classpath, monitor);	
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:18,代码来源:FixProjectsUtils.java

示例12: getSelection

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
@Override
public IClasspathEntry getSelection() {
  IPath path = new Path(Initializer.APGAS_CONTAINER_ID);

  final int index = this.mProjectsCombo.getSelectionIndex();
  if (index != -1) {
    final String selectedProjectName = this.mProjectsCombo.getItem(index);

    if (this.mOwnerProject == null
        || !selectedProjectName.equals(this.mOwnerProject.getName())) {
      path = path.append(selectedProjectName);
    }
  }

  return JavaCore.newContainerEntry(path);
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:17,代码来源:APGASContainerPage.java

示例13: DerbyClasspathContainer

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
public DerbyClasspathContainer() {
    List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
    Bundle bundle = Platform.getBundle(CommonNames.CORE_PATH);
    Enumeration en = bundle.findEntries("/", "*.jar", true);
    String rootPath = null;
    try { 
        rootPath = FileLocator.resolve(FileLocator.find(bundle, new Path("/"), null)).getPath();
    } catch(IOException e) {
        Logger.log(e.getMessage(), IStatus.ERROR);
    }
    while(en.hasMoreElements()) {
        IClasspathEntry cpe = JavaCore.newLibraryEntry(new Path(rootPath+'/'+((URL)en.nextElement()).getFile()), null, null);
        entries.add(cpe);
    }    
    IClasspathEntry[] cpes = new IClasspathEntry[entries.size()];
    _entries = (IClasspathEntry[])entries.toArray(cpes);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:18,代码来源:DerbyClasspathContainer.java

示例14: createClasspath

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
private static void createClasspath(IPath root, List<String> paths, IJavaProject javaProject,
    int javaLanguageLevel) throws CoreException {
  String name = root.lastSegment();
  IFolder base = javaProject.getProject().getFolder(name);
  if (!base.isLinked()) {
    base.createLink(root, IResource.NONE, null);
  }
  List<IClasspathEntry> list = new LinkedList<>();
  for (String path : paths) {
    IPath workspacePath = base.getFullPath().append(path);
    list.add(JavaCore.newSourceEntry(workspacePath));
  }
  list.add(JavaCore.newContainerEntry(new Path(BazelClasspathContainer.CONTAINER_NAME)));

  list.add(
      JavaCore.newContainerEntry(new Path(STANDARD_VM_CONTAINER_PREFIX + javaLanguageLevel)));
  IClasspathEntry[] newClasspath = list.toArray(new IClasspathEntry[0]);
  javaProject.setRawClasspath(newClasspath, null);
}
 
开发者ID:bazelbuild,项目名称:eclipse,代码行数:20,代码来源:BazelProjectSupport.java

示例15: isSourcePath

import org.eclipse.jdt.core.IClasspathEntry; //导入依赖的package包/类
private boolean isSourcePath(String path) throws JavaModelException, BackingStoreException {
  Path pp = new File(instance.getWorkspaceRoot().toString() + File.separator + path).toPath();
  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  for (IClasspathEntry entry : project.getRawClasspath()) {
    if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
      IResource res = root.findMember(entry.getPath());
      if (res != null) {
        String file = res.getLocation().toOSString();
        if (!file.isEmpty() && pp.startsWith(file)) {
          IPath[] inclusionPatterns = entry.getInclusionPatterns();
          if (!matchPatterns(pp, entry.getExclusionPatterns()) && (inclusionPatterns == null
              || inclusionPatterns.length == 0 || matchPatterns(pp, inclusionPatterns))) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
 
开发者ID:bazelbuild,项目名称:eclipse,代码行数:21,代码来源:BazelClasspathContainer.java


注:本文中的org.eclipse.jdt.core.IClasspathEntry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。