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.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


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

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

def inputFiles

def outputFiles 

def action() {"Creating private footer files")

    FooterData ext = project.extensions.docPlugin.getFooterData()"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 -> "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 "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!
    <small>Am ${timestamp.format("dd.MM.yyyy")} um ${timestamp.format("HH:mm")} generiert mit ${ext.asciidoctorVersion}.</small>
""" // Asciidoctor version string as parameter String footerFooter = "
" "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)}


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