當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaRuntime.newDefaultProjectClasspathEntry方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.launching.JavaRuntime.newDefaultProjectClasspathEntry方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaRuntime.newDefaultProjectClasspathEntry方法的具體用法?Java JavaRuntime.newDefaultProjectClasspathEntry怎麽用?Java JavaRuntime.newDefaultProjectClasspathEntry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.launching.JavaRuntime的用法示例。


在下文中一共展示了JavaRuntime.newDefaultProjectClasspathEntry方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createClassLoader

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
@Override
public URLClassLoader createClassLoader() throws SdkException, MalformedURLException {
  IJavaProject userProject = findUserProject();
  if (userProject != null) {
    IRuntimeClasspathEntry outputEntry = JavaRuntime.newDefaultProjectClasspathEntry(userProject);
    try {
      IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry =
          JavaRuntime.resolveRuntimeClasspathEntry(outputEntry, userProject);
      List<URL> urls = new ArrayList<URL>();
      for (IRuntimeClasspathEntry entry : resolveRuntimeClasspathEntry) {
        urls.add(new File(entry.getLocation()).toURI().toURL());
      }

      return new URLClassLoader(urls.toArray(NO_URLS), null);

    } catch (CoreException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }

  // TODO Auto-generated method stub
  return null;
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:25,代碼來源:GWTProjectsRuntime.java

示例2: computeClasspath

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
private static String computeClasspath(GwtSdk gwtRuntime, String[] extraClassPath)
    throws CoreException {
  List<String> cpPaths = new ArrayList<String>();
  for (IClasspathEntry c : gwtRuntime.getClasspathEntries()) {
    if (c.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
      IJavaProject javaProject = JavaProjectUtilities.findJavaProject(c.getPath().toOSString());
      IRuntimeClasspathEntry projectRuntimeEntry = JavaRuntime.newDefaultProjectClasspathEntry(javaProject);
      IRuntimeClasspathEntry[] resolvedEntries = JavaRuntime.resolveRuntimeClasspathEntry(
          projectRuntimeEntry, javaProject);
      for (IRuntimeClasspathEntry resolvedEntry : resolvedEntries) {
        cpPaths.add(resolvedEntry.getLocation());
      }
    } else {
      cpPaths.add(c.getPath().toFile().getAbsolutePath());
    }
  }
  if (extraClassPath != null) {
    cpPaths.addAll(Arrays.asList(extraClassPath));
  }
  return ProcessUtilities.buildClasspathString(cpPaths);
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:22,代碼來源:WebAppProjectCreatorRunner.java

示例3: addProjectEntries

import org.eclipse.jdt.launching.JavaRuntime; //導入方法依賴的package包/類
protected void addProjectEntries(Set<IRuntimeClasspathEntry> resolved, IPath path, int scope, String classifier,
      ILaunchConfiguration launchConfiguration, final IProgressMonitor monitor) throws CoreException {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = root.getProject(path.segment(0));

    IMavenProjectFacade projectFacade = projectManager.create(project, monitor);
    if(projectFacade == null) {
      return;
    }

    ResolverConfiguration configuration = projectFacade.getResolverConfiguration();
    if(configuration == null) {
      return;
    }

    IJavaProject javaProject = JavaCore.create(project);

    boolean projectResolved = false;

    for(IClasspathEntry entry : javaProject.getRawClasspath()) {
      IRuntimeClasspathEntry rce = null;
      switch(entry.getEntryKind()) {
        case IClasspathEntry.CPE_SOURCE:
          if(!projectResolved) {

            IMavenClassifierManager mavenClassifierManager = MavenJdtPlugin.getDefault().getMavenClassifierManager();
            IClassifierClasspathProvider classifierClasspathProvider = mavenClassifierManager
                .getClassifierClasspathProvider(projectFacade, classifier);

            if(IClasspathManager.CLASSPATH_TEST == scope) {
              classifierClasspathProvider.setTestClasspath(resolved, projectFacade, monitor);
            } else {
              classifierClasspathProvider.setRuntimeClasspath(resolved, projectFacade, monitor);
            }

            projectResolved = true;
          }
          break;
        case IClasspathEntry.CPE_CONTAINER:
          IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), javaProject);
          if(container != null && !MavenClasspathHelpers.isMaven2ClasspathContainer(entry.getPath())) {
            switch(container.getKind()) {
              case IClasspathContainer.K_APPLICATION:
                rce = JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(),
                    IRuntimeClasspathEntry.USER_CLASSES, javaProject);
                break;
//                case IClasspathContainer.K_DEFAULT_SYSTEM:
//                  unresolved.add(JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), IRuntimeClasspathEntry.STANDARD_CLASSES, javaProject));
//                  break;
//                case IClasspathContainer.K_SYSTEM:
//                  unresolved.add(JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES, javaProject));
//                  break;
            }
          }
          break;
        case IClasspathEntry.CPE_LIBRARY:
          rce = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath());
          break;
        case IClasspathEntry.CPE_VARIABLE:
          if(!JavaRuntime.JRELIB_VARIABLE.equals(entry.getPath().segment(0))) {
            rce = JavaRuntime.newVariableRuntimeClasspathEntry(entry.getPath());
          }
          break;
        case IClasspathEntry.CPE_PROJECT:
          IProject res = root.getProject(entry.getPath().segment(0));
          if(res != null) {
            IJavaProject otherProject = JavaCore.create(res);
            if(otherProject != null) {
              rce = JavaRuntime.newDefaultProjectClasspathEntry(otherProject);
            }
          }
          break;
        default:
          break;
      }
      if(rce != null) {
        addStandardClasspathEntries(resolved, rce, launchConfiguration);
      }
    }
  }
 
開發者ID:fbricon,項目名稱:wildfly-hive,代碼行數:81,代碼來源:MavenRuntimeClasspathProvider.java


注:本文中的org.eclipse.jdt.launching.JavaRuntime.newDefaultProjectClasspathEntry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。