Exemple #1
0
 private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) {
   IRuntimeClasspathEntry tools = getToolsJar(configuration);
   if (tools == null) {
     if (path != null) {
       // use the global entry
       rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)));
     } else {
       // use the default vm install to try to find a tools.jar
       IVMInstall install = JavaRuntime.getDefaultVMInstall();
       if (install != null) {
         IAntClasspathEntry entry =
             AntCorePlugin.getPlugin()
                 .getPreferences()
                 .getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
         if (entry != null) {
           rtes.add(
               JavaRuntime.newArchiveRuntimeClasspathEntry(
                   new Path(entry.getEntryURL().getPath())));
         }
       }
     }
   } else {
     rtes.add(tools);
   }
 }
Exemple #2
0
  /**
   * Returns the tools.jar to use for this launch configuration, or <code>null</code> if none.
   *
   * @param configuration configuration to resolve a tools.jar for
   * @return associated tools.jar archive, or <code>null</code>
   */
  private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) {
    try {
      IVMInstall install = JavaRuntime.computeVMInstall(configuration);
      if (install != null) {
        IAntClasspathEntry entry =
            AntCorePlugin.getPlugin()
                .getPreferences()
                .getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
        if (entry != null) {
          return JavaRuntime.newArchiveRuntimeClasspathEntry(
              new Path(entry.getEntryURL().getPath()));
        }
      }
    } catch (CoreException ce) {
      // likely dealing with a non-Java project
    }

    return null;
  }
Exemple #3
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()]);
  }