How I do extend the Zip task?

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
}

Try defining an output file for the class. If you run gradle with ‘-i’ it will give you info about why a task is skipped.

Thanks for the advice, but I could not get that to work. Decided to write it as a custom class instead of an extension. The code below isn’t exactly what I wanted, but works.

task prepareNewZip(type: Zip) {
  def srcZipFile = downloadGradle.destinationFile
  def copySpecToUse = copySpec {
    def baseFolder = downloadGradle.distributionNameBase
    into("${baseFolder}/init.d") {
      from 'init.d'
    }
    into("${baseFolder}") {
      from 'config.groovy'
      from 'plugins.gradle'
    }
  }
  def newZipFileName = downloadGradle.destinationFile.name
    archiveName = newZipFileName
  from zipTree(srcZipFile)
  with copySpecToUse
}