1

When enabling jacoco with gradle kotlin dsl it fails because it looks at build.gradle file instead of build.gradle.kts file.

Here is the error :

##[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

- 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'

1 Answer 1

2

Messages

##[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

are produced by AzureDevOps Gradle Task due to usage of option

codeCoverageToolOption: 'jaCoCo'

in your configuration of this task, because implementation of AzureDevOps Gradle Task contains hardcoded value build.gradle:

quoting 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

Sign up to request clarification or add additional context in comments.

3 Comments

Hey @Godin I have written isTestCoverageEnabled = true in my build.gradle.kts so is that enough you mean to say if yes then at which path will it generate the report.
The answer on question about path is in your configuration - you have xml.destination = File("$buildDir/reports/jacoco/report.xml") and reportsDir = file("$buildDir/reports/jacoco")
Hey @Godin I have getting error "Task 'jacocoRootReport' not found in root project" when I build the solution is there any other file do I need to change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.