本文介绍了使用Gradle 5.X在Azure DevOps上生成代码覆盖率报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的项目升级到Gradle 5.6.2.我在Azure DevOps上运行的任务之一是:

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"

升级到Gradle 5.6.2后,运行代码覆盖率报告时出现以下错误:

After upgrading to Gradle 5.6.2 I get the following error when the code coverage reports are run:

根据此答案,对Gradle 5.X中的报告API进行了一些更改.在Azure Devops上使用的JaCoCo版本是否与Gradle 5.X不兼容?如果是这样,我有什么可以做的吗?

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?

推荐答案

请参阅以下拉取请求:与Gradle 5兼容的JaCoCo. x .上个月,由于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):

此外,PR已成功合并.一句话,现在,对于我们的Gradle任务,Jacoco版本与Gradle 5.x兼容,该版本已升级了新语法.

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.

为解决您的问题,建议您最好遵循有问题的链接中的解决方案,以确保build.gradle文件的脚本类似于以下格式:

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")

此外,您还可以检查.

这篇关于使用Gradle 5.X在Azure DevOps上生成代码覆盖率报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:10