我最近将项目与Java 8一起从Java 11升级到Gradle 6.5
但是,当我运行./gradlew pitest命令时,出现以下错误:

Execution failed for task ':pitest'.
> The value for task ':pitest' property 'mainClass' is final and cannot be changed any further.
这是我的pitest中的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
}
这是我的pitest相关的依赖项:
Plugins{
       id "info.solidsoft.pitest" version '1.3.0'
}

testCompile 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.3.0'
我不确定此mainClass属性的来源,也没有找到有关此问题的任何相关答案或文档。

最佳答案

通过将依赖项版本升级到以下版本,我能够解决我的问题:

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


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

增加依赖项版本后,命令./gradlew pitest正常运行,并且pitest运行正常。

08-25 01:50