@Override
  protected void addUserEntries(ClasspathModel model) throws CoreException {

    if (supportLibs != null && supportLibs.length > 0) {
      for (URL supportLib : supportLibs) {
        model.addEntry(
            ClasspathModel.USER,
            JavaRuntime.newStringVariableClasspathEntry(
                new Path(supportLib.getPath()).toOSString()));
      }
    }

    for (IPath libRoot : libRoots) {
      File[] libFiles =
          libRoot
              .toFile()
              .listFiles(
                  new FilenameFilter() {

                    public boolean accept(File dir, String name) {
                      return name.endsWith(".jar");
                    }
                  });

      if (!CoreUtil.isNullOrEmpty(libFiles)) {

        for (File libFile : libFiles) {
          model.addEntry(
              ClasspathModel.USER,
              JavaRuntime.newStringVariableClasspathEntry(libFile.getAbsolutePath()));
        }
      }
    }

    for (String portalLib : portalLibs) {
      model.addEntry(
          ClasspathModel.USER,
          JavaRuntime.newStringVariableClasspathEntry(
              portalDir.append("WEB-INF/lib").append(portalLib).toOSString()));
    }

    if (userLibs != null) {
      for (String userLib : userLibs) {
        model.addEntry(
            ClasspathModel.USER,
            JavaRuntime.newStringVariableClasspathEntry(
                portalDir.append("WEB-INF/lib").append(userLib).toOSString()));
      }
    } else {
      for (String jarFile : this.portalDir.append("WEB-INF/lib").toFile().list()) {
        if (jarFile.endsWith(".jar")) {
          model.addEntry(
              ClasspathModel.USER,
              JavaRuntime.newStringVariableClasspathEntry(
                  portalDir.append("WEB-INF/lib").append(jarFile).toOSString()));
        }
      }
    }
  }
예제 #2
0
  /* (non-Javadoc)
   * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
   */
  public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration)
      throws CoreException {
    boolean separateVM = AntLaunchingUtil.isSeparateJREAntBuild(configuration);
    boolean setInputHandler = configuration.getAttribute(AntLaunching.SET_INPUTHANDLER, true);
    AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
    IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();
    IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries();
    List rtes = new ArrayList(antClasspathEntries.length + userEntries.length);
    IAntClasspathEntry entry;
    for (int i = 0; i < antClasspathEntries.length; i++) {
      entry = antClasspathEntries[i];
      if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
        rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
      }
    }
    boolean haveToolsEntry = false;
    String path;
    for (int i = 0; i < userEntries.length; i++) {
      entry = userEntries[i];
      path = entry.getLabel();
      IPath toolsPath = new Path(path);
      if (toolsPath.lastSegment().equals("tools.jar")) { // $NON-NLS-1$
        haveToolsEntry = true;
        // replace with dynamically resolved tools.jar based on
        // the JRE being used
        addToolsJar(configuration, rtes, path);
      } else {
        rtes.add(JavaRuntime.newStringVariableClasspathEntry(path));
      }
    }
    if (!haveToolsEntry) {
      addToolsJar(configuration, rtes, null);
    }

    if (setInputHandler && separateVM) {
      addSWTJars(rtes);
    }

    return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
  }