Skip to content

Instantly share code, notes, and snippets.

@int128 int128/script.groovy
Created Mar 20, 2019

Embed
What would you like to do?
Create a ZIP/JAR file in Groovy
/**
* Create a ZIP/JAR file with given contents.
*
* @param destination destination file
* @param contents map of filename and content
*/
void createZIP(File destination, Map<String, String> contents) {
destination.withOutputStream {
new ZipOutputStream(it).withStream { zip ->
contents.each { filename, content ->
zip.putNextEntry(new ZipEntry(filename))
zip << content
zip.closeEntry()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.