Jacoco multimodule setup - error resolving external dependencies

I have a multi module setup for jacoco. When running the report task an error is shown indicating that external dependencies can’t be resolved

Execution failed for task ':codeCoverageReport'.
> Could not resolve all files for configuration ':jacocoAnt'.
   > Cannot resolve external dependency org.jacoco:org.jacoco.ant:0.8.5 because no repositories are defined.
     Required by:
         project :

The build.gradle is as follows

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        mavenCentral()
    }
}

plugins {
    id 'java-library'
    id 'groovy'
    id 'org.unbroken-dome.test-sets' version '2.2.1' apply false
    id 'org.sonarqube' version '2.8' apply false
    id 'jacoco'
}

ext {
    groovyMinorVersion = '2.5'
    groovyVersion = "${groovyMinorVersion}.8"
    spockVersion = "1.3-groovy-${groovyMinorVersion}"
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'groovy'
    apply plugin: 'org.unbroken-dome.test-sets'

    repositories {
        mavenCentral()
    }

    task compileClasses() {
        dependsOn classes
        dependsOn testClasses
    }

    testSets {
        if (file('src/componentTest').exists()) {
            componentTest
            compileClasses.dependsOn componentTestClasses
            check.dependsOn tasks.componentTest
        }
        if (file('src/integrationTest').exists()) {
            integrationTest
            compileClasses.dependsOn integrationTestClasses
            check.dependsOn tasks.integrationTest
        }
    }

    dependencies {
        testImplementation "org.codehaus.groovy:groovy:${groovyVersion}"
        testImplementation "org.spockframework:spock-core:${spockVersion}"
    }
}


subprojects {
    apply plugin: 'jacoco'
    jacoco {
        toolVersion = "0.8.6"
    }
}

tasks.register("codeCoverageReport", JacocoReport) {
    // If a subproject applies the 'jacoco' plugin, add the result it to the report

    subprojects { subproject ->
        subproject.plugins.withType(JacocoPlugin).configureEach {
            subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).configureEach { testTask ->
                sourceSets subproject.sourceSets.main
                executionData(testTask)
            }

            // To automatically run `test` every time `./gradlew codeCoverageReport` is called,
            // you may want to set up a task dependency between them as shown below.
            // Note that this requires the `test` tasks to be resolved eagerly (see `forEach`) which
            // may have a negative effect on the configuration time of your build.
            subproject.tasks.matching({ t -> t.extensions.findByType(JacocoTaskExtension) }).forEach {
                rootProject.tasks.codeCoverageReport.dependsOn(it)
            }
        }
    }

    // enable the different report types (html, xml, csv)
    reports {
        // xml is usually used to integrate code coverage with
        // other tools like SonarQube, Coveralls or Codecov
        xml.enabled true

        // HTML reports can be used to see code coverage
        // without any external tools
        html.enabled true
    }
}

The part that does the report task setup is from Reporting code coverage with JaCoCo Sample. I’m using Gradle 6.4!

You are not defining any repositories (besides build script repositories which are for resolving build script dependencies, not production dependencies)
Besides that there is a gradlePluginPortal() helper.