Пример #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);
        }
      }
    }
  }