16

Changing enabled to required throws an error in gradle 7.5

> Configure project :
The Report.enabled property has been deprecated. This is scheduled to be removed in Gradle 8.0. Please use the required property instead. See https://docs.gradle.org/7.5/dsl/org.gradle.api.reporting.Report.html#org.gradle.api.reporting.Report:enabled for more details.

 jacocoTestReport {
     reports {
-        xml.enabled false
-        csv.enabled false
-        html.enabled true
+        xml.required false
+        csv.required false
+        html.required true
     }
 }

> Could not find method required() for arguments [false] on Report xml of type org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport.
Rpj
  • 5,348
  • 16
  • 62
  • 122

2 Answers2

32

required is a property, not a method. This should help:

Groovy DSL (build.gradle)

jacocoTestReport {
    reports {
        xml.required = false
        csv.required = false
        html.required = true
    }
}

Kotlin DSL (build.gradle.kts)

tasks.jacocoTestReport {
    reports {
        xml.required.set(false)
        csv.required.set(false)
        html.required.set(true)
    }
}

See: JaCoCo Report configuration

thokuest
  • 5,800
  • 24
  • 36
  • Getting errors on 8.0.2 with `xml.required = true` (Could not find method required() for arguments [true] on Report xml of type org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport.) – Tasos Zervos Jul 21 '23 at 14:30
  • @TasosZervos Just tested with Gradle 8.0.2. `xml.required = true` just works fine. Syntax is correct as per [Docs: JaCoCo Report configuration](https://docs.gradle.org/8.0.2/userguide/jacoco_plugin.html#sec:jacoco_report_configuration). – thokuest Jul 21 '23 at 16:11
  • Correction (I couldn't edit the comment when I've noticed) - I am using version 8.2.1. I will try again and with 8.0.2 and see if it's related to this or something else. – Tasos Zervos Jul 23 '23 at 09:46
  • It looks like the issue for me was only related to IntelliJ complaining about it. – Tasos Zervos Jul 24 '23 at 15:15
6

For gradle 8.2.1 I have found that previous answers also fail.

This has worked for me:

jacocoTestReport {
    reports {
        xml.required.set(false)
        csv.required.set(false)
        html.required.set(true)
    }
}
Tasos Zervos
  • 526
  • 1
  • 6
  • 8