`group(name: subproject.name)` This is working in...
# community-support
a
group(name: subproject.name)
This is working in gradle-7.2 but failing in gradle-7.6.4 How to fix this ?
Error:
Caused by: java.lang.IllegalArgumentException: Value is null
Copy code
task jacocoRootReport {
    FileCollection executionData = files()
    def modulesToIgnore = ['projectA', 'projectB', 'projectC', 'projectD', 'projectE']
    subprojects.findAll { subproject ->
        subproject.pluginManager.hasPlugin('java') && subproject.pluginManager.hasPlugin('jacoco') && !modulesToIgnore.contains(subproject.name)
    }.each { subproject ->
        executionData += subproject.tasks.jacocoTestReport.executionData
    }

    executionData = files(executionData.findAll {
        it.exists()
    })

    ant.taskdef(name: 'jacocoReport', classname: 'org.jacoco.ant.ReportTask',
            classpath: configurations.jacocoAnt.asPath)

    ant.jacocoReport {
        executiondata {
            executionData.addToAntBuilder(ant, 'resources')
        }
        structure(name: project.name) {
            subprojects.findAll { subproject ->
                subproject.pluginManager.hasPlugin('java') && subproject.pluginManager.hasPlugin('jacoco') && !modulesToIgnore.contains(subproject.name)
            }.each { subproject ->
                group(name: subproject.name) {
                    if (subproject.name != 'orchestrator') {
                        classfiles {
                            ((FileCollection) files("${subproject.buildDir}/classes"))
                                    .filter { it.exists() }
                                    .addToAntBuilder(ant, 'resources')
                        }
                    } else {
                        classfiles {
                            fileTree(
                                    dir: "${subproject.buildDir}/classes",
                                    excludes: ['**/test/**',
                                               '**/perf/**',
                                               '**/sources/**',
                                               '**/cli/**',
                                               '**/VdtLiteReferenceApp*']).filter {
                                it.exists()
                            }.addToAntBuilder(ant, 'resources')
                        }
                    }
                    sourcefiles {
                        files((Set<File>) subproject.sourceSets.main.allJava.srcDirs).filter {
                            it.exists()
                        }.addToAntBuilder(ant, 'resources')
                    }
                }
            }
        }
        html(destdir: "${buildDir}/reports/jacoco/${name}/html")
        xml(destfile: "${buildDir}/reports/jacoco/${name}/${name}.xml")
        // Uncomment for CSV
        //csv(destfile: "${buildDir}/reports/jacoco/${name}/${name}.csv")
    }
}
Copy code
dependencies {
        classpath 'org.jacoco:org.jacoco.ant:0.8.8'
    }
Copy code
$ ./gradlew --version

------------------------------------------------------------
Gradle 7.6.4
------------------------------------------------------------

Build time:   2024-02-05 14:29:18 UTC
Revision:     e0bb3fc8cefad8432c9033cdfb12dc14facc9dd9

Kotlin:       1.7.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          11.0.23 (<http://Amazon.com|Amazon.com> Inc. 11.0.23+9-LTS)
OS:           Linux 5.15.160-104.158.amzn2.x86_64 amd64
v
It's actually a pretty bad idea to reach into other projects model. Cross-configuring another project already is highly discouraged and evil. But retrieving values from the other model is probably even worse, as you would require that other project to be evaluated already which might not be the case. If what you want is a JaCoCo report over all projects, you should probably have a look at the
jacoco-report-aggregation
plugin instead.
a
Okay. But something changed b/w gradle 7.2 & 7.6.4 which is breaking this ? It's working in this state since inception of project
v
Maybe you were just lucky and some detail changed. I cannot tell you what changed to cause this without debugging the code probably. I just thought I tell you that what you do there is anyway discouraged and at best flaky and risky. 🙂