Search code examples
javagradlepitest

PITest Issue: property 'mainClass' is final and cannot be changed any further


I have recently upgraded my project from Java 8 to Java 11 alongside Gradle 6.5. However, when I run the command ./gradlew pitest I receive the following error:

Execution failed for task ':pitest'.
> The value for task ':pitest' property 'mainClass' is final and cannot be changed any further.

Here is my pitest set-up in my build.gradle:

pitest {
    pitestVersion = '1.4.3'
    targetClasses = ['com.myproject.*']
    excludedClasses = [
            'com.myproject.configuration.*',
            'com.myproject.controller.*',
    ]
    threads = 10
    enableDefaultIncrementalAnalysis = true
    historyInputLocation = ['build/reports/pitest/fastermutationtesting']
    historyOutputLocation = ['build/reports/pitest/fastermutationtestingoutput']
    outputFormats = ['XML', 'HTML']
    timestampedReports = true
    mutationThreshold = 90   
}

and here are my pitest related dependencies:

Plugins{
       id "info.solidsoft.pitest" version '1.3.0'
}

testCompile 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.3.0'

I am not sure where this mainClass property is coming from and have not found any related answers or documentation on this issue.


Solution

  • I was able to resolve my issue by upgrading the dependency versions to:

    id "info.solidsoft.pitest" version '1.5.1'
    

    and

    testCompile 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.4.0'
    

    after increasing the dependency versions, the command ./gradlew pitest was working as normal and the pitests were running fine.