예제 #1
0
  /**
   * adapt recursively
   *
   * @param file
   * @param elements
   * @param container
   */
  private void adapt(File file, List<IElement> elements, IElement container) {
    FileElement newElement = null;
    if (PluginInfosExtractor.isAPlugin(file)) {
      try {
        // Unzipped plugin
        if (file.isDirectory()) {
          newElement =
              PluginInfosExtractor.getPluginInfosFromManifest(
                  file.getAbsolutePath() + "/META-INF/MANIFEST.MF");
        } else {
          // Jar plugin
          newElement = PluginInfosExtractor.getPluginInfosFromJar(file.getAbsolutePath());
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else {
      newElement = new FileElement();
    }

    // Set the relevant information
    newElement.setUri(file.toURI());
    newElement.setRelativeURI(rootURI.relativize(file.toURI()));

    // Add dependency to the parent folder
    if (container != null) {
      newElement.addDependency("container", container);
    }

    // Add the bundles info
    if (newElement instanceof PluginElement) {
      PluginElement plugin = (PluginElement) newElement;
      String line = bundlesInfoLines.get(plugin.getSymbName());
      // in the case of source code plugins, line will be null but no
      // problem
      plugin.setBundleInfoLine(line);

      if (plugin.getName() == null || plugin.getName().contains("%")) {
        System.out.println(
            "EclipseAdapter.adapt() No name found for: "
                + plugin.isFragment()
                + "  "
                + plugin.getSymbName());
      }
    }

    // Add to the list
    elements.add(newElement);

    // Go for the files in case of folder
    if (file.isDirectory()) {
      // Exclude the features folder
      if (!newElement.getRelativeURI().toString().equals("features/")) {
        File[] files = file.listFiles();
        for (File subFile : files) {
          adapt(subFile, elements, newElement);
        }
      }
    }
  }
예제 #2
0
  /**
   * Provides the atomic elements (plugins) this distribution is made of
   *
   * @param uri URI of the distribution
   * @param monitor
   */
  @Override
  public List<IElement> adapt(URI uri, IProgressMonitor monitor) {

    List<IElement> elements = new ArrayList<IElement>();
    File file = FileUtils.getFile(uri);
    rootURI = file.toURI();

    // A hashmap of bundle symbolic names and the complete line in the
    // bundles.info file
    bundlesInfoLines = PluginInfosExtractor.createBundlesInfoMap(uri);

    // start the containment tree traversal, with null as initial container
    adapt(file, elements, null);

    // plugin dependencies
    for (IElement elem : elements) {
      if (elem instanceof PluginElement) {
        PluginElement pe = (PluginElement) elem;
        DependenciesBuilder.build(pe, elements);
      }
    }

    // in elements we have the result
    return elements;
  }