Skip to content

Commit

Permalink
We have to use an arg provider :-|
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Dec 10, 2024
1 parent 965aa5c commit 4987113
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +818,14 @@ subprojects {

// This uses advzip: https://linux.die.net/man/1/advzip
def optimizeZip = tasks.register('optimizeZip', Exec) {
dependsOn makeZip
description = "Optimizes the NeoForm ZIP-file in-place"
commandLine "advzip", "--recompress", "-k", "-4", makeZip.flatMap(Zip::getArchiveFile)
if (optimize_zip) {
mustRunAfter makeZip
}
commandLine "advzip", "--recompress", "-k", "-4"
argumentProviders.add(
objects.newInstance(ZipPathArgumentProvider).tap {
file = makeZip.flatMap(AbstractArchiveTask::getArchiveFile)
}
)
}
if (optimize_zip) {
makeZip.configure { finalizedBy optimizeZip }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.minecraftforge.mcpconfig.tasks

import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.process.CommandLineArgumentProvider

abstract class ZipPathArgumentProvider implements CommandLineArgumentProvider {
@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
abstract RegularFileProperty getFile()

@Override
Iterable<String> asArguments() {
[file.get().asFile.absolutePath]
}
}

0 comments on commit 4987113

Please sign in to comment.