Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 'testFrameworkProperty' is final and cannot be changed any further with gradle 8.2

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
    }
}
like image 975
SeleniumUser Avatar asked Oct 15 '25 09:10

SeleniumUser


2 Answers

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.

like image 107
Francisco Mateo Avatar answered Oct 19 '25 00:10

Francisco Mateo


I changed my gradle version to 7.3.3 from 7.3.0 and it worked.

like image 26
AkashJodd Avatar answered Oct 18 '25 22:10

AkashJodd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!