I am trying to migrate my gradle build.gradle file from gradle 7.6 to gradle 8.2 version but while doing migration I am getting below error: The value for task 'smoke' property 'testFrameworkProperty' is final and cannot be changed any further.
I am not sure what it is I need to do further. Can someone help me please? Here is the code so far I have got:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
group 'com.orgs.project'
version '1.0'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
dependencies {
implementation group: 'javax.json', name: 'javax.json-api', version: '1.1.4'
implementation group: 'org.glassfish', name: 'javax.json', version: '1.1'
testImplementation 'org.apache.logging.log4j:log4j-core:2.10.0'
testImplementation 'org.apache.logging.log4j:log4j-api:2.10.0'
testImplementation 'io.cucumber:cucumber-java:3.0.2'
}
tasks.create(name: "smoke", type: Test) {
outputs.upToDateWhen { false }
ignoreFailures = true
finalizedBy(aggregate)
group = "Environments"
doFirst {
systemProperties System.properties
if (System.properties.getProperty("${region}")) {
project.logger.lifecycle("Running tests against:")
}
useJUnitPlatform {
if (project.hasProperty('includeTags')) {
includeTags project.getProperty('includeTags')
}
project.logger.lifecycle("Targeting tags:${tags}")
includeTags "${tags}"
excludeTags 'Progress'
}
}
}
tasks.withType(Test) {
// maxParallelForks=2
testLogging {
events "FAILED",
"SKIPPED",
"STANDARD_ERROR",
"STANDARD_OUT"
exceptionFormat "FULL"
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
}
}
You cannot change/mutate the useJUnitPlatform once it has been finalized. This is what you are doing in the doFirst { } which is during the task execution phase after the property has been finalized.
Move the useJUnitPlatform configuration above the doFirst { } block.
I changed my gradle version to 7.3.3 from 7.3.0 and it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With