private void xmlReadSelectedElements(JarPackageData jarPackage, Element element)
     throws java.io.IOException {
   if (element.getNodeName().equals("selectedElements")) { // $NON-NLS-1$
     jarPackage.setExportClassFiles(
         getBooleanAttribute(element, "exportClassFiles")); // $NON-NLS-1$
     jarPackage.setExportOutputFolders(
         getBooleanAttribute(element, "exportOutputFolder", false)); // $NON-NLS-1$
     jarPackage.setExportJavaFiles(getBooleanAttribute(element, "exportJavaFiles")); // $NON-NLS-1$
     NodeList selectedElements = element.getChildNodes();
     Set<IAdaptable> elementsToExport = new HashSet<IAdaptable>(selectedElements.getLength());
     for (int j = 0; j < selectedElements.getLength(); j++) {
       Node selectedNode = selectedElements.item(j);
       if (selectedNode.getNodeType() != Node.ELEMENT_NODE) continue;
       Element selectedElement = (Element) selectedNode;
       if (selectedElement.getNodeName().equals("file")) // $NON-NLS-1$
       addFile(elementsToExport, selectedElement);
       else if (selectedElement.getNodeName().equals("folder")) // $NON-NLS-1$
       addFolder(elementsToExport, selectedElement);
       else if (selectedElement.getNodeName().equals("project")) // $NON-NLS-1$
       addProject(elementsToExport, selectedElement);
       else if (selectedElement.getNodeName().equals("javaElement")) // $NON-NLS-1$
       addJavaElement(elementsToExport, selectedElement);
       // Note: Other file types are not handled by this writer
     }
     jarPackage.setElements(elementsToExport.toArray());
   }
 }
  public static File exportProjectToJarFile(IProject project, boolean logInfo) {

    JarPackageData jarExportOps = new JarPackageData();
    jarExportOps.setExportJavaFiles(false);
    jarExportOps.setExportClassFiles(true);
    jarExportOps.setIncludeDirectoryEntries(true);
    jarExportOps.setUsesManifest(false);
    jarExportOps.setOverwrite(true);
    jarExportOps.setJarBuilder(new LambdaFunctionJarBuilder());

    try {

      Object[] elements = getElementsToExport(project);
      jarExportOps.setElements(elements);

      // prefix should be at least three characters long
      File jarFile = File.createTempFile(project.getName() + "-lambda", ".zip");
      jarFile.deleteOnExit();

      jarExportOps.setJarLocation(new Path(jarFile.getAbsolutePath()));

      if (logInfo) {
        LambdaPlugin.getDefault()
            .logInfo(
                String.format(
                    "Exporting project [%s] to %s", project.getName(), jarFile.getAbsolutePath()));
      }

      IJarExportRunnable runnable = jarExportOps.createJarExportRunnable(null);
      runnable.run(null);

      if (logInfo) {
        LambdaPlugin.getDefault().logInfo("Project exported to " + jarFile.getAbsolutePath());
      }

      return jarFile;

    } catch (Exception e) {
      LambdaPlugin.getDefault()
          .reportException(
              String.format("Unable to export project [%s] to jar file", project.getName()), e);
      return null;
    }
  }