Пример #1
0
 private void xmlReadManifest(JarPackageData jarPackage, Element element)
     throws java.io.IOException {
   if (element.getNodeName().equals("manifest")) { // $NON-NLS-1$
     jarPackage.setManifestVersion(element.getAttribute("manifestVersion")); // $NON-NLS-1$
     jarPackage.setUsesManifest(getBooleanAttribute(element, "usesManifest")); // $NON-NLS-1$
     jarPackage.setReuseManifest(getBooleanAttribute(element, "reuseManifest")); // $NON-NLS-1$
     jarPackage.setSaveManifest(getBooleanAttribute(element, "saveManifest")); // $NON-NLS-1$
     jarPackage.setGenerateManifest(
         getBooleanAttribute(element, "generateManifest")); // $NON-NLS-1$
     jarPackage.setManifestLocation(
         Path.fromPortableString(element.getAttribute("manifestLocation"))); // $NON-NLS-1$
     jarPackage.setManifestMainClass(getMainClass(element));
     xmlReadSealingInfo(jarPackage, element);
   }
 }
  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;
    }
  }