azure-pipelines-tasks: Gradle task with Jacoco code coverage fails after upgrade to Gradle 7

Bug
Type: build task fails

Enter Task Name: Gradle,v2

Environment

  • Azure Pipelines

    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number:

Gradle+Jacoco: https://dev.azure.com/slb-swt/ai-planning/_build/results?buildId=4043438&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=ea098990-53e4-52aa-5a84-5ead7c5f17f2&l=167

  • Agent - Hosted or Private:

    • If using Hosted agent, provide agent queue name: hosted

Issue Description

Yaml pipeline:


pool:
  vmImage: 'ubuntu-latest'

steps:
  - task: Gradle@2
    inputs:
      gradleWrapperFile: 'gradlew'
      tasks: 'build'
      publishJUnitResults: true
      testResultsFiles: '**/TEST-*.xml'
      codeCoverageToolOption: 'JaCoCo'
      codeCoverageClassFilesDirectories: 'build/classes/java/main/'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '1.11'
      gradleOptions: '-Xmx3072m'
      sonarQubeRunAnalysis: false
      spotBugsAnalysis: false

Gradle.properties

gradleVersion=7.4.2

Gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Task logs

> Task :processTestResources
> Task :testClasses
> Task :test
> Task :jacocoTestReport FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/home/vsts/work/1/s/build.gradle' line: 70

* What went wrong:
Execution failed for task ':jacocoTestReport'.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 4
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Any updates on this issue please?

This problem is caused by the Gradle task writing the following to the build.gradle file

// build.gradle classDirectories.setFrom fileTree(dir: “build/classes/java/main/”).exclude(jacocoExcludes).include(jacocoIncludes)

In Gradle 6.x and later, classDirectories is read-only. JacocoReport - Gradle DSL Version 7.6.1

In Gradle 5.x, it was possible to write values to classDirectories, so the problem did not occur. JacocoReport - Gradle DSL Version 5.6.4

Any updates on this issue please?

Thanks @kaito-ms and @jan-dolejsi for highlighting this issue.

I am also running into this and interested in a resolution!

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

I am also interested in an update on this. Nice investigation/root cause analysis @kaito-ms

Hi @jan-dolejsi Thank you for your report, We are working on more prioritized issues at the moment but will get back to this one soon.