I wrote a plugin to execute a native executable in multiple subprojects. The native executable is extracted from a ZIP archive into the build-directory of the project. I now have the problem that this ZIP is unpacked in every project the plugin is applied to which takes a lot of time and resources, since the ZIP archive is about 100MB. Is there a proper way to only extract the ZIP archive once into a central directory wihtout having overlapping task outputs?
Here is a rough draft of what the plugin does:
val binaries by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
}
dependencies {
binaries("org.example:binaries:1.0.0+build.1337") {
artifact {
extension = "zip"
}
}
}
val unzipBinaryExecutable by tasks.registering(Sync::class) {
from(zipTree(binaries))
into(project.layout.buildDirectory.dir("extracted-binaries"))
}
val executeBinary by tasks.registering {
inputs.files(unzipBinaryExecutable)
doLast {
// do stuff with
}
}
// some more complex configuration