當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。