Skip to content

Commit 25b77ce

Browse files
committed
Safely access jacoco in setFrom() backports, too
1 parent fc4a125 commit 25b77ce

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

android-junit5/src/main/groovy/de/mannodermaus/gradle/plugins/junit5/GroovyInterop.groovy

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ class GroovyInterop {
163163
* @param paths Paths to apply
164164
*/
165165
static void jacocoReportBase_executionData_setFrom(JacocoReportBase report, Project project, Object... paths) {
166-
if (report.executionData instanceof ConfigurableFileCollection) {
166+
def val = jacocoReportBase_getExecutionData(report)
167+
if (val instanceof ConfigurableFileCollection) {
167168
// In Gradle 5.0+, executionData is a ConfigurableFileCollection
168-
report.executionData.setFrom(paths)
169+
val.setFrom(paths)
169170
} else {
170171
// Below, use the mutator method to configure the data
171172
report.executionData = project.files(paths)
@@ -181,9 +182,10 @@ class GroovyInterop {
181182
* @param paths Paths to apply
182183
*/
183184
static void jacocoReportBase_classDirectories_setFrom(JacocoReportBase report, Project project, Object... paths) {
184-
if (report.classDirectories instanceof ConfigurableFileCollection) {
185+
def val = jacocoReportBase_getClassDirectories(report)
186+
if (val instanceof ConfigurableFileCollection) {
185187
// In Gradle 5.0+, executionData is a ConfigurableFileCollection
186-
report.classDirectories.setFrom(paths)
188+
val.setFrom(paths)
187189
} else {
188190
// Below, use the mutator method to configure the data
189191
report.classDirectories = project.files(paths)
@@ -199,9 +201,10 @@ class GroovyInterop {
199201
* @param paths Paths to apply
200202
*/
201203
static void jacocoReportBase_sourceDirectories_setFrom(JacocoReportBase report, Project project, Object... paths) {
202-
if (report.sourceDirectories instanceof ConfigurableFileCollection) {
204+
def val = jacocoReportBase_getSourceDirectories(report)
205+
if (val instanceof ConfigurableFileCollection) {
203206
// In Gradle 5.0+, executionData is a ConfigurableFileCollection
204-
report.sourceDirectories.setFrom(paths)
207+
val.setFrom(paths)
205208
} else {
206209
// Below, use the mutator method to configure the data
207210
report.sourceDirectories = project.files(paths)

0 commit comments

Comments
 (0)