}
ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(zipFile));
zipOutputStream.setLevel(0);
DirZipper zipper = new DirZipper();
zipper.setInputStreamProvider(new PluginISProvider(_designDirectory, obfuscate));
zipper.addFilePatternToIgnore("^\\..*$");
// Zip all folders and files that belong into an exported plugin
List<File> filesToZip = new ArrayList<File>();
filesToZip.add(new File(_designDirectory, DesignDirectory.FOLDERNAME_TML));
filesToZip.add(new File(_designDirectory, DesignDirectory.FOLDERNAME_SCRIPT));
filesToZip.add(new File(_designDirectory, DesignDirectory.FOLDERNAME_FILES));
filesToZip.add(new File(_designDirectory, DesignDirectory.SYNCINFO_FILE));
filesToZip.add(new File(_designDirectory, DesignDirectory.DESIGN_DEFINITION_FILE));
Iterator<File> files = filesToZip.iterator();
while (files.hasNext()) {
File file = (File) files.next();
if (file.exists()) {
if (file.isDirectory()) {
zipper.zipDirectory(file, zipOutputStream, file.getName() + "/");
}
else {
zipper.zipFile(file, zipOutputStream);
}
}
}
// If the design directory has a java classes folder we put those into a jar and zip them to "files/system"
File javaClassesDir = new File(_designDirectory, DesignDirectory.FOLDERNAME_JAVA);
if (javaClassesDir.exists() && javaClassesDir.isDirectory()) {
TemporaryFile jar = new TemporaryFile("plugin-classes.jar", null, null);
ZipOutputStream jarStream = new ZipOutputStream(new FileOutputStream(jar.getFile()));
jarStream.setLevel(0);
DirZipper jarZipper = new DirZipper();
jarZipper.addFilePatternToIgnore("^\\..*$");
jarZipper.zipDirectory(javaClassesDir, jarStream);
jarStream.close();
zipper.zipNormalFile(jar.getFile(), zipOutputStream, "files/system/");
jar.delete();
}
// If we were given a java source folder we put its contents into plugin-sources.zip and put that into "files/system" (for OSS plugins)
if (javaSourceFolder != null) {
File javaSourceDir = new File(javaSourceFolder);
TemporaryFile zip = new TemporaryFile("plugin-sources.zip", null, null);
ZipOutputStream zipStream = new ZipOutputStream(new FileOutputStream(zip.getFile()));
zipStream.setLevel(0);
DirZipper jarZipper = new DirZipper();
jarZipper.addFilePatternToIgnore("^\\..*$");
jarZipper.zipDirectory(javaSourceDir, zipStream);
zipStream.close();
zipper.zipNormalFile(zip.getFile(), zipOutputStream, "files/system/");