JacocoTaskExtension and JacocoPluginExtension in 6.1.1

I am trying to apply Jacoco to a cucumber task, and I think the JacocoTaskExtension contains the capabilities Im missing, but I dont know how to add it to my task. I have a JacocoPluginExtension, but that appears to be a different thing.

plugins {
    id 'java'
    id 'jacoco'
    id "org.sonarqube" version "2.8"

sourceSets {
    itest {
        compileClasspath += main.output
        runtimeClasspath += main.output

configurations {
    cucumberRuntime.extendsFrom testImplementation
    itestImplementation.extendsFrom testImplementation
    itestRuntime.extendsFrom testRuntime

task cucumber() {
    dependsOn assemble, compileItestJava, test
    jacoco { }

    doLast {
        javaexec {
            main = "io.cucumber.core.cli.Main"
            jvmArgs = ['-javaagent:src/itest/resources/jacocoagent.jar=destfile=build/jacoco/cucumber.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false']
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.itest.output
            args = ['--plugin', 'pretty', '--glue', 'cuke', 'src/itest/resources']

jacocoTestReport {
    executionData fileTree(project.rootDir.absolutePath).include("build/jacoco/*.exec")
    dependsOn test,cucumber
    reports {
        xml.enabled true
        csv.enabled false

This is the build.gradle. I have a workaround for the jacoco agent, as you see, but I think using the JacocoTaskExtension would allow me to get it properly applied to the javaExec clause.

The “jacoco {}” adds the JacocoPluginExtension; perhaps a different name would also get me the JacocoTaskExtension?

This isnt urgent, because the workaround you see is getting me the jacoco data I need, for now, but it will be brittle as the version of jacoco used by the jacoco plugins changes.