kordamp / kordamp-gradle-plugins

A collection of Gradle plugins
https://kordamp.org/kordamp-gradle-plugins/
Apache License 2.0
138 stars 25 forks source link

Multiple project and includeProjectDependencies flag - jacoco plugin #494

Closed chicuongle closed 1 year ago

chicuongle commented 2 years ago

I have a big project with hundreds of sub modules. Not all of these sub projects are java sub projects. Jacoco plugin is configured only for java sub projects. All java sub projects have dependency on a 'java-platform' sub project in order to fix dependencies version. The 'java-platform' sub project is not a java sub project and it causes an issue for using includeProjectDependencies. Because the platform sub project does not have any source dir. My project structure looks like following:

rootProject

Including project dependencies logic does check only "ProjectDependency" and not check about characters of "java" project (see https://docs.gradle.org/current/userguide/java_plugin.html).

if (config.coverage.jacoco.includeProjectDependencies) {
                project.configurations.findByName(testTask.name + 'Implementation').allDependencies.each { d ->
                    if (d instanceof ProjectDependency) projects << d.dependencyProject
                }
                project.configurations.findByName(testTask.name + 'RuntimeOnly').allDependencies.each { d ->
                    if (d instanceof ProjectDependency) projects << d.dependencyProject
                }
            }
            t.additionalSourceDirs.from project.files(resolveSourceDirs(config, projects))
            t.additionalClassDirs.from project.files(resolveClassDirs(config, projects))
            t.sourceDirectories.from project.files(resolveSourceDirs(config, projects))
            t.classDirectories.from project.files(resolveClassDirs(config, projects))

The simple checking logic in this place can cause issue in resolveSourceDirs. Either we have to extend logic in this place or to include logic in resolveSourceDirs (and resolveClassDirs) in order to get rid of different ProjectDependency and only use "java" ProjectDependency

aalmiray commented 1 year ago

Completed with https://github.com/kordamp/kordamp-gradle-plugins/commit/db14cc04a6e109ec0bcc5d7bf182cbec6a5aa992