-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move some processors to a separate file
- Loading branch information
Showing
3 changed files
with
37 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import groovy.json.JsonOutput | ||
import groovy.json.JsonSlurper | ||
import java.io.File | ||
import java.util.jar.JarEntry | ||
import java.util.jar.JarInputStream | ||
import java.util.jar.JarOutputStream | ||
import java.util.zip.Deflater | ||
|
||
object Compressors { | ||
val json = { input: File -> | ||
input.outputStream().write(JsonOutput.toJson(JsonSlurper().parse(input)).toByteArray()) | ||
} | ||
|
||
val storeJars = { input: File -> | ||
val tmp = input.copyTo(File.createTempFile(input.nameWithoutExtension, ".jar"), overwrite = true) | ||
JarInputStream(tmp.inputStream()).use { ins -> | ||
JarOutputStream(input.outputStream()).use { out -> | ||
out.setLevel(Deflater.NO_COMPRESSION) | ||
while (true) { | ||
out.putNextEntry(JarEntry((ins.nextEntry ?: break).name)) | ||
ins.copyTo(out) | ||
out.closeEntry() | ||
ins.closeEntry() | ||
} | ||
|
||
out.finish() | ||
out.flush() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters