Generating code coverage reports on Azure DevOps with Gradle 5.X

一个人想着一个人 提交于 2019-12-11 15:27:21

问题


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 type org.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!