How to declare outputfiles in task class without loosing auto. cleanTask

Hi there,
want to optimize my custom plugin. The plugin takes a Filetree with asciidoc files as input and generates for each input file a private-footer-file. The name of each output file is know in advance.

This is the task configuration in a build.gradle:

generateFooterFiles {
    inputFiles = fileTree('ci_build_maintenance') {
        include docPlugin.footerData.includePattern
        exclude docPlugin.footerData.excludePattern
    }
    outputFiles = inputFiles.collect {
        FilenameUtils.concat(docPlugin.footerData.docsRoot,
                FilenameUtils.getBaseName(it.toString()) + docPlugin.footerData.footerExt)
    }
}

I’m (desperately) looking for a way to move the configuration of the outputfiles into my plugin/task class. I use @OutputFiles annotation for the outputFiles Property, because I want to have an incremental task and also an automatically generated cleanGenerateFooterFiles task. I have to use @OutputFiles over @OutputDirectory, because the generated files are written into a directory where already other files exist. So gradle has to know each generated file individually instead of just one output directory.
Here is the task class:

package de.hmmh.itsqs.docPlugin

import org.gradle.api.DefaultTask
import org.gradle.api.logging.Logger
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputFiles
import org.gradle.api.tasks.TaskAction
import org.slf4j.LoggerFactory

import java.nio.file.Path
import java.nio.file.Paths

import org.apache.commons.io.FilenameUtils

class GenerateFooterTask extends DefaultTask {
// Logging in gradle plugin - #2 by lingocoder
private static final Logger LOG = LoggerFactory.getLogger(“GenerateFooterTask”) as Logger

GenerateFooterTask() {
    setGroup("docPlugin")
    setDescription("generates private footer files for all adoc")
}

@InputFiles
def inputFiles

@OutputFiles
def outputFiles 

@TaskAction
def action() {
    logger.info("Creating private footer files")

    FooterData ext = project.extensions.docPlugin.getFooterData()
    LOG.info("Configuration: ${ext.toString()}")

    if (inputFiles.size() != outputFiles.size())
        throw new IllegalArgumentException("Error: Number of inputFiles != number of outputFiles")

    Path pathBase = Paths.get(ext.docsRoot)

    inputFiles.each { File inFile ->
        logger.info "Processing: ${inFile}"

// due to adoc issues (see comment on top): String footerfname = FilenameUtils.removeExtension(pathRelative) + “-docinfo-footer.html”
String footerfname = FilenameUtils.concat(ext.docsRoot.toString(), FilenameUtils.getBaseName(inFile.toString()) + ext.footerExt)

        // check if there is an outputFile declared for each inputFile
        if (outputFiles.findAll ({ it.toString().equals(footerfname) }).size() != 1)
            throw new IllegalArgumentException("Error: No outputFile declared for ${footerfname}")

        String pathRelative = pathBase.relativize(inFile.toPath()).toString()
        String bbDocUrl = ext.bbBaseUrl + FilenameUtils.separatorsToUnix(pathRelative) // URLs use always unix style slashes
        logger.info "RepoDocUrl: ${bbDocUrl}"
        Date timestamp = new Date()

        String footerHeader = """
<div id='footer-text style="rgba(0, 0, 0, 0.8)">' """ String footerContent = """

The IT-SQS Index

Gebt uns Feedback per Pull-Request!
<div>
    <small>Am ${timestamp.format("dd.MM.yyyy")} um ${timestamp.format("HH:mm")} generiert mit ${ext.asciidoctorVersion}.</small>
</div>
""" // Asciidoctor version string as parameter String footerFooter = "
" logger.info "Creating footerfile: '${footerfname}'"
        new File(footerfname).withWriter('utf-8') {writer ->
            footerHeader.eachLine {line -> writer.writeLine(line)}
            footerContent.eachLine {line -> writer.writeLine(line)}
            footerFooter.eachLine {line -> writer.writeLine(line)}
            writer.flush()
        }
    }
}

}

Any help appreciated. I already investeted many hours in recherche on this issue.
Thank you in advance.