Incremental task with output depending on input

Hello, I have another question concerning incremental tasks.
I have a task that runs perfectly based on its inputs :

class GenerateTextTask extends DefaultTask {
    @InputFiles
    def File[] txtDir = new File(txtPath).listFiles(new FilenameFilter() {
        @Override
        boolean accept(File dir, String name) {
            return name.endsWith(".txt")
        }
    })

    @Input
    def langs = "en"

    @OutputFiles
    def List<File> xmlFiles = langs.split(" ").collect {lang ->
        new File("output/${lang}.xml")
    }

But the problem here is if I extends this tasks :

task hello(type: GenerateTextTask) {
    langs = "en fr"
}

the output is only output/en.xml (because langs as not be injected yet).

What can I do to solve this issue ?

Change it from a field to a getter

@OutputFiles 
List<File> getXmlFiles() { ... } 

Also, don’t use new File(...) use project.file(...) instead

Thank you it works perfectly (after 1 hour of trial and error) !!