Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
 private void addSWTJars(List rtes) {
   if (fgSWTEntries == null) {
     fgSWTEntries = new ArrayList();
     Bundle bundle = Platform.getBundle("org.eclipse.swt"); // $NON-NLS-1$
     BundleDescription description =
         Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
     BundleDescription[] fragments = description.getFragments();
     for (int i = 0; i < fragments.length; i++) {
       Bundle fragmentBundle = Platform.getBundle(fragments[i].getName());
       URL bundleURL;
       try {
         bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); // $NON-NLS-1$
       } catch (IOException e) {
         AntLaunching.log(e);
         continue;
       }
       String urlFileName = bundleURL.getFile();
       if (urlFileName.startsWith("file:")) { // $NON-NLS-1$
         try {
           urlFileName = new URL(urlFileName).getFile();
           if (urlFileName.endsWith("!/")) { // $NON-NLS-1$
             urlFileName = urlFileName.substring(0, urlFileName.length() - 2);
           }
         } catch (MalformedURLException e) {
           AntLaunching.log(e);
           continue;
         }
       }
       IPath fragmentPath = new Path(urlFileName);
       if (fragmentPath.getFileExtension() != null) { // JAR file
         fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
       } else { // folder
         File bundleFolder = fragmentPath.toFile();
         if (!bundleFolder.isDirectory()) {
           continue;
         }
         String[] names =
             bundleFolder.list(
                 new FilenameFilter() {
                   public boolean accept(File dir, String name) {
                     return name.endsWith(".jar"); // $NON-NLS-1$
                   }
                 });
         for (int j = 0; j < names.length; j++) {
           String jarName = names[j];
           fgSWTEntries.add(
               JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
         }
       }
     }
   }
   rtes.addAll(fgSWTEntries);
 }
  private IRuntimeClasspathEntry convertClasspathEntry(IClasspathEntry entry) {
    if (entry == null) return null;

    IPath srcPath = entry.getSourceAttachmentPath();
    if (srcPath != null && srcPath.segmentCount() > 0) {
      IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath());
      rte.setSourceAttachmentPath(srcPath);
      rte.setSourceAttachmentRootPath(entry.getSourceAttachmentRootPath());
      return rte;
    }
    return null;
  }
Exemplo n.º 4
0
  /** @see ITomcatVersionHandler#getRuntimeClasspath(IPath, IPath) */
  public List getRuntimeClasspath(IPath installPath, IPath configPath) {
    List<IRuntimeClasspathEntry> cp = new ArrayList<IRuntimeClasspathEntry>();

    // 8.0 - add bootstrap.jar and tomcat-juli.jar from the Tomcat bin directory
    IPath binPath = installPath.append("bin");
    if (binPath.toFile().exists()) {
      IPath path = binPath.append("bootstrap.jar");
      cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
      // Add tomcat-juli.jar if it exists
      path = binPath.append("tomcat-juli.jar");
      if (path.toFile().exists()) {
        cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
      }
      // If tomcat-juli.jar is not found in the install, check the config directory
      else if (configPath != null) {
        path = configPath.append("bin/tomcat-juli.jar");
        if (path.toFile().exists()) {
          cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
        }
      }
    }

    return cp;
  }
  protected List getStartClasspath() {
    List startClasspath = super.getStartClasspath();
    GenericServerRuntime runtime = getRuntimeDelegate();

    IVMInstall vmInstall = runtime.getVMInstall();
    File jdkLib = new File(vmInstall.getInstallLocation(), "lib");

    if (jdkLib.exists() && jdkLib.isDirectory()) {
      for (String cpath : jdkLib.list()) {
        Path newCPath = new Path(new File(jdkLib, cpath).toString());
        String fileExtension = newCPath.getFileExtension();
        if (fileExtension != null && fileExtension.equalsIgnoreCase("jar"))
          startClasspath.add(JavaRuntime.newArchiveRuntimeClasspathEntry(newCPath));
      }
    }
    return startClasspath;
  }
Exemplo n.º 6
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;
  }