问题
I'm trying to upgrade my project to Gradle 5.6.2. One of the tasks that I run on Azure DevOps is:
- task: Gradle@2
displayName: 'Test Project'
inputs:
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx7000m'
sonarQubeRunAnalysis: true
sonarQubeGradlePluginVersion: 2.6.2
testRunTitle: $(DISPLAY_NAME)
codeCoverageToolOption: JaCoCo
publishJUnitResults: true
testResultsFiles: '**/build/test-results/test/TEST-*.xml'
tasks: "test -Dtest.profile=unit --parallel"
After upgrading to Gradle 5.6.2 I get the following error when the code coverage reports are run:
Could not find method
destination()for arguments [/home/vsts/work/1/s/batch/build/jacocoHtml] on Report html of typeorg.gradle.api.reporting.internal.TaskGeneratedSingleDirectoryReport
According to this answer, some changes were made to the reporting API in Gradle 5.X. Is the version of JaCoCo that's used on Azure Devops incompatible with Gradle 5.X? If so, is there anything I can do about this?
回答1:
Some changes were made to the reporting API in Gradle 5.X, Is the version of JaCoCo that's used on Azure Devops incompatible with Gradle 5.X?
See this pull request: JaCoCo compatible with gradle 5.x. Last month, we raised a pull request to improve our Gradle task script since the feature has changed in Gradle 5.x(see this changes):
Also, the PR has been merged successfully. In one word, now, for our Gradle task, the Jacoco version is compatible with Gradle 5.x which has upgrade the new syntax.
To solve your issue, I suggest you'd better follow the solution which in the link you shared in question, to ensure the script of your build.gradle file is similar as the below format:
destination file("$xx/xxx/xx.xml")
Also, you can check this thread.
来源:https://stackoverflow.com/questions/58398359/generating-code-coverage-reports-on-azure-devops-with-gradle-5-x