diff --git a/src/main/kotlin/com/example/Main.kt b/src/main/kotlin/com/example/Main.kt index f46bdb4..48c71aa 100644 --- a/src/main/kotlin/com/example/Main.kt +++ b/src/main/kotlin/com/example/Main.kt @@ -82,10 +82,11 @@ fun reZip3(jarIn: File, srcJar: File, zipOut: File) { val tmp = Files.createTempFile(MANIFEST, ".tmp").toFile() tmp.writeText("Manifest-Version: 1.0\r\nCreated-By: ReZip3\r\nMain-Class: com.beust.kobalt.MainKt\r\n") - val entry = zos.createArchiveEntry(tmp, "META-INF/$MANIFEST") - zos.putArchiveEntry(entry) - IOUtils.copy(tmp.inputStream(), zos) - zos.closeArchiveEntry() + addEntry(zos, tmp, "META-INF/$MANIFEST") + + val kobaltw = File(System.getProperty("user.home") + "/.kobalt/wrapper/dist/kobalt-1.0.60/bin/kobaltw") + + addEntry(zos, kobaltw, "bin/${kobaltw.name}") src.close() zos.close() @@ -94,6 +95,14 @@ fun reZip3(jarIn: File, srcJar: File, zipOut: File) { println("ReZip-3 Time: $time ms") } +// Add an archive entry +fun addEntry(zos: ZipArchiveOutputStream, file: File, path: String) { + val entry = zos.createArchiveEntry(file, path) + zos.putArchiveEntry(entry) + IOUtils.copy(file.inputStream(), zos) + zos.closeArchiveEntry() +} + // Look for duplicate entries fun entryExists(jarEntries: Enumeration, entry: ZipArchiveEntry): Boolean { for (e in jarEntries) {