I want to extend the Zip task to take in a zip file, run a copyspec against it, then create a new zip file. Below is my attempt. I’m stuck with what to put into the @TaskAction section.
This compiles and runs, but says all is up to date without producing the new zip file.
class PrepareNewZip extends Zip {
@InputFile srcZipFile
@Input CopySpec copySpec
@Input String newZipName
@TaskAction doIt() {
archiveName = newZipName
from zipTree(srcZipFile)
with copySpec
}
}
task prepareNewZip(type: PrepareNewZip, dependsOn: downloadGradle) {
srcZipFile = downloadGradle.destinationFile
copySpec = copySpec {
def baseFolder = downloadGradle.distributionNameBase
into("${baseFolder}/init.d") {
from 'init.d'
}
into("${baseFolder}") {
from 'config.groovy'
from 'plugins.gradle'
}
}
newZipName = downloadGradle.destinationFile.name
}