Could not get unknown property 'compileConfigurationName' for source set 'main' error whilst updating Gradle from version 6.4.1 to 7.1

I am getting the following error while updating Gradle.
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property ‘compileConfigurationName’ for source set ‘main’ of type org.gradle.api.internal.tasks.DefaultSourceSet.
at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)

My build.gradle looks like this:

plugins {
id ‘application’
id ‘java’
id ‘jacoco’
// id ‘checkstyle’
id ‘io.spring.dependency-management’ version ‘1.0.11.RELEASE’
id ‘org.springframework.boot’ version ‘2.3.9.RELEASE’
id ‘org.owasp.dependencycheck’ version ‘6.2.2’
id ‘net.ltgt.apt’ version ‘0.10’
id ‘com.github.ben-manes.versions’ version ‘0.36.0’
id ‘org.sonarqube’ version ‘3.1.1’
id ‘au.com.dius.pact’ version ‘4.1.0’
id ‘io.freefair.lombok’ version ‘5.3.0’
}

group = ‘uk.gov.hmcts.ethos.replacement’
version = ‘0.0.1’

//checkstyle {
// maxWarnings = 0
//
// toolVersion = ‘8.29’
// // need to set configDir to rootDir otherwise submodule will use submodule/config/checkstyle
// configDir = new File(rootDir, ‘config/checkstyle’)
//}

allprojects {
sourceCompatibility = ‘11.0’
targetCompatibility = ‘11.0’
}

jacocoTestReport {
executionData(test)
reports {
xml.enabled = true
csv.enabled = false
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}

jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.0
}
}
}
}

def sonarExclusions = [’/uk/gov/hmcts/ethos/replacement/docmosis/config/’,
/uk/gov/hmcts/ethos/replacement/docmosis/model/’,
/uk/gov/hmcts/reform/ethos/replacement/docmosis/CaseOrchestrationApplication’,
'
/uk/gov/hmcts/ethos/replacement/docmosis.config.DevQueueClient.java’
]

sonarqube {
properties {
property “sonar.exclusions”, sonarExclusions.join(’, ')
property “sonar.projectKey”, “ethos-repl-docmosis-service”
property “sonar.dynamicAnalysis”, “reuseReports”
property “sonar.dependencyCheck.reportPath”, “${project.buildDir}/reports/dependency-check-report.xml”
property “sonar.coverage.jacoco.xmlReportPaths”, “${jacocoTestReport.reports.xml.destination.path}”
}
}

project.tasks[‘sonarqube’].dependsOn jacocoTestReport

sourceSets {
test {
java.srcDir ‘src/test/java’
}
functional {
java.srcDir ‘src/test/functional/java’
resources.srcDir ‘src/test/functional/resources’
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
contractTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
java.srcDir ‘src/test/contractTest/java’
resources.srcDir ‘src/test/contractTest/resources’
}
resources.srcDir file(‘src/test/contractTest/resources’)
}
}

configurations {
functionalImplementation.extendsFrom testImplementation
functionalRuntimeOnly.extendsFrom testRuntimeOnly
contractTestImplementation.extendsFrom testImplementation
contractTestRuntimeOnly.extendsFrom testRuntimeOnly
}

test {
exclude ‘**/ComponentTest
}

task smoke(type: Test, description: ‘Runs the smoke tests.’, group: ‘Verification’) {
testClassesDirs = sourceSets.functional.output.classesDirs
classpath = sourceSets.functional.runtimeOnlyClasspath

useJUnit {
    includeCategories 'uk.gov.hmcts.ethos.replacement.functional.SmokeTest'
}
systemProperty('VAULTNAME', System.getenv('VAULTNAME'))

}

task functional(type: Test, description: ‘Runs the functional tests.’, group: ‘Verification’) {
testClassesDirs = sourceSets.functional.output.classesDirs
classpath = sourceSets.functional.runtimeOnlyClasspath

useJUnit {
    includeCategories 'uk.gov.hmcts.ethos.replacement.functional.SmokeTest'
}

systemProperty('VAULTNAME', System.getenv('VAULTNAME'))

maxHeapSize = '1G'

}

project.ext {
pacticipant = ‘ethos_replDocmosisService’
pacticipantVersion = getCheckedOutGitCommitHash()
}

def getCheckedOutGitCommitHash() {
‘git rev-parse --verify --shirt HEAD’.execute().text.trim()
}

task runContractTests(type: Test, description: ‘Runs contract tests.’, group: ‘Verification’) {
onlyIf {
return System.env.SKIP_CONTRACT_TESTS == null || System.env.SKIP_CONTRACT_TESTS == ‘false’
}
useJUnitPlatform()
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeOnlyClasspath
systemProperty ‘pact.rootDir’, “pacts”
testLogging.showStandardStreams = true
}

task runAndPublishConsumerPactTests(type: Test, description: ‘Publish pact test to broker.’, group: ‘Verification’) {
logger.lifecycle(“Runs pact consumer Tests”)

testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeOnlyClasspath

}

runAndPublishConsumerPactTests.finalizedBy pactPublish

pact {
broker {
pactBrokerUrl = System.getenv(“PACT_BROKER_FULL_URL”) ?: ‘http://localhost:80
}
publish {
pactDirectory = ‘pacts’
tags = [System.getenv(“PACT_BRANCH_NAME”) ?: ‘Dev’]
version = project.pacticipantVersion
}
}

// dependency-check – Tasks
dependencyCheck {
// Specifies if the build should be failed if a CVSS score above a specified level is identified.
// range of 0-10 fails the build, anything greater and it doesn’t fail the build
failBuildOnCVSS = System.getProperty(‘dependencyCheck.failBuild’) == ‘true’ ? 0 : 11
suppressionFile = ‘config/owasp/suppressions.xml’
analyzers.assemblyEnabled = false
}

repositories {
mavenCentral()
jcenter()
maven { url “https://dl.bintray.com/hmcts/hmcts-maven” }
maven { url “http://repo.maven.apache.org/maven2” }
maven { url ‘https://repo.spring.io/libs-milestone’ }
maven { url “https://jitpack.io” }
}

def versions = [
springfoxSwagger: ‘2.9.2’,
logging : ‘5.1.7’,
serenity : ‘2.3.31’,
pact_version : ‘4.1.7’
]

dependencies {
implementation ‘org.springframework.boot:spring-boot-starter-web’
implementation ‘org.springframework.boot:spring-boot-starter-actuator’
implementation ‘org.springframework.boot:spring-boot-configuration-processor’
implementation ‘org.springframework.boot:spring-boot-starter-data-jpa’
implementation ‘org.springframework.retry:spring-retry’

implementation 'org.postgresql:postgresql:42.2.19'

implementation group: 'io.springfox', name: 'springfox-swagger2', version: versions.springfoxSwagger
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: versions.springfoxSwagger
implementation group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '9.7'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'



implementation 'com.github.hmcts:ecm-common:0.1.86'



implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.2.5.RELEASE'
implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: '11.1'
implementation group: 'io.github.openfeign', name: 'feign-core', version: '11.1'

implementation group: 'uk.gov.hmcts.reform', name: 'document-management-client', version: '6.0.0'
implementation group: 'uk.gov.hmcts.reform', name: 'logging', version: versions.logging
implementation group: 'uk.gov.hmcts.reform', name: 'logging-appinsights', version: versions.logging
implementation group: 'uk.gov.hmcts.reform', name: 'properties-volume-spring-boot-starter', version:'0.1.0'

implementationOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

testImplementation 'org.springframework.boot:spring-boot-starter-test'

testImplementation (group: 'org.docx4j', name: 'docx4j', version: '6.1.2') {
    exclude module: 'slf4j-log4j12'
}
testImplementation group: 'com.auth0', name: 'java-jwt', version: '3.14.0'
testImplementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
testImplementation group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
testImplementation group: 'com.warrenstrange', name: 'googleauth', version: '1.5.0'

testImplementation group: 'net.serenity-bdd', name: 'serenity-core', version: versions.serenity
testImplementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: versions.serenity, {
    exclude module: 'jaxb-osgi'
}
testImplementation group: 'net.serenity-bdd', name: 'serenity-junit', version: versions.serenity
testImplementation group: 'net.serenity-bdd', name: 'serenity-spring', version: versions.serenity

// Contract Tests
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: versions.pact_version
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'java8', version: versions.pact_version
contractTestImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.3.9.RELEASE'
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit_jupiter
contractTestRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: versions.junit_jupiter
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: versions.junit_jupiter
contractTestRuntimeOnly group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.7.0'
contractTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.4'
contractTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.4'
contractTestImplementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.2.7.RELEASE'
contractTestImplementation group: 'org.springframework.cloud', name: 'spring-cloud-netflix-ribbon', version: '2.2.7.RELEASE'

contractTestImplementation sourceSets.main.runtimeClasspath
contractTestImplementation sourceSets.test.runtimeClasspath

}

bootJar {
getArchiveFileName().set(provider {
‘ethos-repl-docmosis-service.jar’
})

manifest {
    attributes('Implementation-Version': project.version.toString())
}

}

wrapper {
distributionType = Wrapper.DistributionType.ALL
}

The property SourceSet.compileConfigurationName has been deprecated for a long time and was removed in Gradle 7. The error is probably coming from one of the plugins you’re applying.

Running Gradle with -s should give you a full stack trace and should help narrow down which plugin is trying to access that property. Once you determine that, check to see if there is a newer version that is compatible with Gradle 7.