Cannot set PMD parameters with kotlin

I’m trying to set the parameters “maxFailures” or “incrementalAnalysis” of the PMD extension in a kotlin build script, but the values are read only. Please give an example how to set these parameters.

I tried:

tasks {
    withType<Pmd>() {
        enabled = isPmdEnabled
        ignoreFailures = false
        reports {
            xml.isEnabled = true
            html.isEnabled = false
        isConsoleOutput = true
        // the above all work fine!
        maxFailures = 150 // <-- this fails!

and the same in the

pmd {

section. None worked.

Ok, found it myself… The PMD Plugin uses the Provider API (
That means, that values are set calling e.g.