private static void processLibrariesAndJpsPlugins(File jarFile,
                                                    File zipFile,
                                                    String pluginName,
                                                    Set<Library> libs,
                                                    Map<Module, String> jpsModules) throws IOException {
    if (FileUtil.ensureCanCreateFile(zipFile)) {
      try (Compressor zip = new Compressor.Zip(zipFile)) {
        zip.addDirectory(getZipPath(pluginName, ""));

        Set<String> usedFileNames = new HashSet<>();
        String entryName = pluginName + JAR_EXTENSION;
        zip.addFile(getZipPath(pluginName, entryName), jarFile);
        usedFileNames.add(entryName);

        for (Map.Entry<Module, String> entry : jpsModules.entrySet()) {
          File jpsPluginJar = jarModulesOutput(Collections.singleton(entry.getKey()), null, null);
          try {
            zip.addFile(getZipPath(pluginName, entry.getValue()), jpsPluginJar);
          }
          finally {
            FileUtil.delete(jpsPluginJar);
          }
        }

        Set<VirtualFile> jarredVirtualFiles = new HashSet<>();
        for (Library library : libs) {
          VirtualFile[] roots = library.getFiles(OrderRootType.CLASSES);
          for (VirtualFile libRoot : roots) {
            if (jarredVirtualFiles.add(libRoot)) {
              if (libRoot.getFileSystem() instanceof JarFileSystem) {
                addLibraryFile(libRoot, pluginName, zip, usedFileNames);
              }
              else {
                makeAndAddLibraryJar(libRoot, pluginName, zip, usedFileNames, library.getName());
              }
            }
          }
          VirtualFile[] nativeRoots = library.getFiles(NativeLibraryOrderRootType.getInstance());
          for (VirtualFile root : nativeRoots) {
            if (!root.isDirectory()) {
              addLibraryFile(root, pluginName, zip, usedFileNames);
            }
          }
        }
      }
    }
  }
private static void processLibrariesAndJpsPlugins(File jarFile,
                                                    File zipFile,
                                                    String pluginName,
                                                    Set<Library> libs,
                                                    Map<Module, String> jpsModules)