Skip to content

Commit

Permalink
enable nested jar uncompression and actually fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Jul 16, 2024
1 parent 94fcaad commit d96706d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
cache-read-only: false

- name: do the build
run: ./gradlew assemble squishJar
run: ./gradlew assemble
continue-on-error: true

- name: upload artifacts
Expand Down
33 changes: 20 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import xyz.wagyourtail.unimined.internal.minecraft.task.RemapJarTaskImpl
import xyz.wagyourtail.unimined.util.OSUtils
import xyz.wagyourtail.unimined.util.sourceSets
import xyz.wagyourtail.gradle.shadow.ShadowJar
import java.util.jar.JarEntry
import java.util.jar.JarInputStream
import java.util.jar.JarOutputStream
import java.util.zip.Deflater
Expand Down Expand Up @@ -290,19 +291,25 @@ val compressJar = tasks.register<ProcessJar>("compressJar") {
it.outputStream().write(JsonOutput.toJson(json).toByteArray())
}

// addFileProcessor("jar") { // store jar files with no compression
// val tmp = it.copyTo(File.createTempFile(it.nameWithoutExtension, ".jar"), overwrite = true)
// JarOutputStream(it.outputStream()).use { jos ->
// jos.setLevel(Deflater.NO_COMPRESSION)
// JarInputStream(tmp.inputStream()).use { ins ->
// while (true) {
// val entry = ins.nextJarEntry ?: break
// jos.putNextEntry(entry)
// ins.copyTo(jos)
// }
// }
// }
// }
addFileProcessor("jar") { // store jar files with no compression
val tmp = it.copyTo(File.createTempFile(it.nameWithoutExtension, ".jar"), overwrite = true)
JarInputStream(tmp.inputStream()).use { ins ->
JarOutputStream(it.outputStream()).use { out ->
out.setLevel(Deflater.NO_COMPRESSION)
var entry: JarEntry? = ins.nextEntry as JarEntry?
while (entry != null) {
out.putNextEntry(JarEntry(entry.name))
ins.copyTo(out)
out.closeEntry()
ins.closeEntry()
entry = ins.nextEntry as JarEntry?
}

out.finish()
out.flush()
}
}
}

addDirProcessor { dir -> // proguard
val temp = temporaryDir.resolve("proguard")
Expand Down

0 comments on commit d96706d

Please sign in to comment.