Error: The value for this file collection is final and cannot be changed. JaCoCo and Gradle 7.6.1

Hi,

I’m using Gradle 7.6.1 and I run into the following problem when runing JaCoCo.

* Where:

Build file '/home/vsts/work/1/s/build.gradle' line: 136

* What went wrong:

Execution failed for task ':jacocoTestReport'.

> The value for this file collection is final and cannot be changed.

My build.gradle is as follows:

plugins {
	id 'java'
	id 'jacoco'
}

test {
	useJUnitPlatform()
	finalizedBy jacocoTestReport // report is always generated after tests run
}

jacoco {
	toolVersion = "0.8.10"
}

jacocoTestReport {
	dependsOn test // tests are required to run before generating the report
}

Any idea what is causing this error?

Regards,

Can you provide a build --scan? (or at least more output, especially including --stacktrace as the error suggests.

Hi @Vampire,

I got same issue. The grade config work well on my PC and github action but when I move to Azure pipeline it expose the error. You can refer below stacktrace:


	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:333)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:320)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:313)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:299)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:143)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:227)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:218)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:140)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)


Can you please share the full stacktrace, or optimally a build --scan?
The stacktrace part you posted is just a part, and not a meaningful one.

Also, if it works locally and on GHA, but not on Azure pipeline, my best guess would be, that you do not use the Gradle wrapper on Azure pipeline, but some preinstalled Gradle version with which your build is not compatible with. To avoid such problems each and every Gradle build should imho include the four wrapper files and always the wrapper used to execute a given build.

Hi @Vampire
Here is log with build --scan

> Task :jacocoTestReport FAILED
Downloading https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.ant/0.8.7/org.jacoco.ant-0.8.7.pom to /home/vsts/.gradle/.tmp/gradle_download7914129849062331169bin
Downloading https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.core/0.8.7/org.jacoco.core-0.8.7.pom to /home/vsts/.gradle/.tmp/gradle_download5340686114642760799bin
Downloading https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.report/0.8.7/org.jacoco.report-0.8.7.pom to /home/vsts/.gradle/.tmp/gradle_download18341687140524289248bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm-commons/9.1/asm-commons-9.1.pom to /home/vsts/.gradle/.tmp/gradle_download2817645023097016968bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.pom to /home/vsts/.gradle/.tmp/gradle_download1277743166862816621bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/ow2/1.5/ow2-1.5.pom to /home/vsts/.gradle/.tmp/gradle_download14542050688544117023bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm-tree/9.1/asm-tree-9.1.pom to /home/vsts/.gradle/.tmp/gradle_download12574058302873888448bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/9.1/asm-analysis-9.1.pom to /home/vsts/.gradle/.tmp/gradle_download34789552595618385bin
Excluding []
Downloading https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.ant/0.8.7/org.jacoco.ant-0.8.7.jar to /home/vsts/.gradle/.tmp/gradle_download8299280049680545968bin
Downloading https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.report/0.8.7/org.jacoco.report-0.8.7.jar to /home/vsts/.gradle/.tmp/gradle_download7498499355039595466bin
Downloading https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.core/0.8.7/org.jacoco.core-0.8.7.jar to /home/vsts/.gradle/.tmp/gradle_download11572102837912041431bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm-commons/9.1/asm-commons-9.1.jar to /home/vsts/.gradle/.tmp/gradle_download6512371177435553826bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/9.1/asm-analysis-9.1.jar to /home/vsts/.gradle/.tmp/gradle_download3960284144938914453bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm-tree/9.1/asm-tree-9.1.jar to /home/vsts/.gradle/.tmp/gradle_download9884744021290193088bin
Downloading https://repo.maven.apache.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.jar to /home/vsts/.gradle/.tmp/gradle_download5717723395832120210bin
Custom actions are attached to task ':jacocoTestReport'.
Caching disabled for task ':jacocoTestReport' because:
  Build cache is disabled
  Gradle does not know how file 'CCReport43F6D5EF' was created (output property 'reports.enabledReports.html.outputLocation'). Task output caching requires exclusive access to output paths to guarantee correctness (i.e. multiple tasks are not allowed to produce output in the same location).
Task ':jacocoTestReport' is not up-to-date because:
  No history is available.
Watching 183 directories to track changes
Watching 184 directories to track changes

You again just posted a non-helpful excerpt.
If you run with --scan, the relevant part is the link to the generated build scan at the very end of the output.