gpt4 book ai didi

android - 如何使用Kotlin DSL Gradle启用代码覆盖?

转载 作者:行者123 更新时间:2023-12-02 13:43:50 27 4
gpt4 key购买 nike

当使用gradle kotlin dsl启用jacoco时,它将失败,因为它查看的是build.gradle文件而不是build.gradle.kts文件。

这是错误:

##[warning]Unable to append code coverage data: Error: File or folder doesn't exist: /home/vsts/work/1/s/build.gradle
##[warning]Failed to enable code coverage: Unable to append code coverage data: Error: File or folder doesn't exist: /home/vsts/work/1/s/build.gradle

app / build.gradle.kts
plugins {
jacoco
}

tasks.withType(JacocoReport::class.java).all {
reports {
xml.isEnabled = true
xml.destination = File("$buildDir/reports/jacoco/report.xml")
}
}

tasks.withType<Test> {
jacoco {
toolVersion = "0.8.3"
reportsDir = file("$buildDir/reports/jacoco")
}
finalizedBy("jacocoTestReport")
}

Azure DevOps任务
- task: Gradle@2
displayName: Gradle Build
inputs:
gradleWrapperFile: 'gradlew'
tasks: ':app:assembleDevDebug :networking:lintDebug :app:lintDevDebug --warning-mode all'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
sonarQubeRunAnalysis: false
codeCoverageToolOption: 'jaCoCo'

最佳答案

留言内容

##[warning]Unable to append code coverage data: Error: File or folder doesn't exist: /home/vsts/work/1/s/build.gradle
##[warning]Failed to enable code coverage: Unable to append code coverage data: Error: File or folder doesn't exist: /home/vsts/work/1/s/build.gradle

AzureDevOps Gradle Task由于使用option而产生
codeCoverageToolOption: 'jaCoCo'

在此任务的配置中,因为AzureDevOps Gradle Task的实现包含硬编码的值 build.gradle:
  • https://github.com/Microsoft/azure-pipelines-tasks/blob/9818b165441796437ca881c3f01bd7d90ee6856e/Tasks/GradleV2/gradletask.ts#L66
  • https://github.com/microsoft/azure-pipelines-tasks/issues/9340

  • 引用 comment from the above bug ticket

    The way for you to use code coverage would be to enable it in your build config files and publish them using another task - PublishCodeCoverageResults

    关于android - 如何使用Kotlin DSL Gradle启用代码覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60935873/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com