Beispiel #1
0
  /**
   * @return the resolved classpath for the launch configuration. All entries, not just user
   *     entries, are returned.
   * @throws CoreException
   */
  public static String[] resolveClasspath(ILaunchConfiguration config) throws CoreException {
    IRuntimeClasspathEntry[] entries =
        JavaRuntime.resolveRuntimeClasspath(
            JavaRuntime.computeUnresolvedRuntimeClasspath(config), config);

    String[] paths = new String[entries.length];
    for (int i = 0; i < entries.length; i++) {
      paths[i] = entries[i].getLocation();
    }
    return paths;
  }
  private static IPath[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
    IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(configuration);
    entries = JavaRuntime.resolveRuntimeClasspath(entries, configuration);

    ArrayList<IPath> userEntries = new ArrayList<IPath>(entries.length);
    for (int i = 0; i < entries.length; i++) {
      if (entries[i].getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {

        String location = entries[i].getLocation();
        if (location != null) {
          IPath entry = Path.fromOSString(location);
          if (!userEntries.contains(entry)) {
            userEntries.add(entry);
          }
        }
      }
    }
    return userEntries.toArray(new IPath[userEntries.size()]);
  }
Beispiel #3
0
  /**
   * Verifies that the classpath entry is valid and won't cause the launch to fail.
   *
   * @param entry The entry to validate.
   * @param serverProject The project that the test server will run out of.
   * @return true if it's valid
   */
  public static boolean classpathEntryIsValid(String entry, IProject serverProject) {
    try {
      ILaunchConfigurationType type =
          DebugPlugin.getDefault()
              .getLaunchManager()
              .getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
      ILaunchConfigurationWorkingCopy copy = type.newInstance(null, "ezeTemp"); // $NON-NLS-1$
      copy.setAttribute(
          IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, serverProject.getName());
      copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);

      List<String> classpath = new ArrayList<String>(1);
      classpath.add(entry);
      copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);

      JavaRuntime.resolveRuntimeClasspath(
          JavaRuntime.computeUnresolvedRuntimeClasspath(copy), copy);
      return true;
    } catch (CoreException ce) {
      return false;
    }
  }