当前位置: 首页>>代码示例>>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;未经允许,请勿转载。