Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convention plugin + filtering projects #582

Closed
igorromcy opened this issue Mar 25, 2024 · 7 comments
Closed

Convention plugin + filtering projects #582

igorromcy opened this issue Mar 25, 2024 · 7 comments
Assignees
Labels
Question Support request issue type S: in progress Status: implementing or design in process

Comments

@igorromcy
Copy link

Hey there!

I'm wondering how I should use kover for this case:

I need to configure kover using my convention plugin because I want to run using a filtered list of projects.
But looks like we need to configure the main build.gradle file anyway, so I'm not sure how we can avoid configuration conflicts there, is there any default configuration we can leave there to merge all the reports generated by my convention plugin kover configuration? 

this is how I'm using it so far, but I think allProjects won't work the way I need

kover {
    merge {
        allProjects()
        createVariant("coverage") {
            it.addWithDependencies(["fastDebug", "debug"] as String[], true)
        }
    }
}
@igorromcy igorromcy added Question Support request issue type S: untriaged Status: issue reported but unprocessed labels Mar 25, 2024
@shanshin
Copy link
Collaborator

Hi,
you would like the names of the projects in which you want to apply Kover to be specified in the applied project? Or how do you want to filter projects?

@igorromcy
Copy link
Author

I want to filter like you said last week

kover {
    merge {
        allProjects {
            it.path in setOf(":feature:login", ":feature:signup") // or for Groovy  [":feature:login", ":feature:signup"]
        }
    }
}

but the problem is that I still need to configure the main build.gradle file anyway, so I can merge all the filtered projects

@shanshin
Copy link
Collaborator

shanshin commented Mar 25, 2024

kover { merge { ... DSL it was designed just so that there was no need to create a convention plugin for Kover, and all the settings needed to be specified in only one project.

If, for some reason, it becomes necessary to use a convention plugin, then it is enough to create an project extension to configure this convention plugin.

Example
Convention Plugin

interface KoverSettings {
    val projects: ListProperty<String>
}

val settingsExtension = extensions.create<KoverSettings>("koverSettings")

kover {
    merge {
        allProjects {
            it.path in settingsExtension.projects.get()
        }
    }
}

Project (kts)

extensions.configure<My_plugin_gradle.KoverSettings> {
    projects.addAll(":feature:login", ":feature:signup")
}

or Project (Groovy)

koverSettings {
    projects.addAll(":feature:login", ":feature:signup")
}

*name My_plugin_gradle will be different for you and depends on the name of the convention plugin
** it is strictly not recommended to put the configuring of KoverSettings extension in the afterEvaluate block

@shanshin shanshin added S: in progress Status: implementing or design in process and removed S: untriaged Status: issue reported but unprocessed labels Mar 26, 2024
@igorromcy
Copy link
Author

igorromcy commented Mar 27, 2024

that's great, I could make it works via convention plugin!

I'm now curious about this scenario: I have 2 shards running for example 50 and 100 modules respectively (2 different steps on pipeline)

Is it possible with kover to merge the reports after both executions?

I was trying to do that via the root build.gradle file + convention plugin, but it seems that we have conflicts, is that possible? (my convention plugin doesn't cover the main build.gradle file)

@igorromcy
Copy link
Author

In other words, I want to merge all the projects which has coverage file generated (on the main build.gradle file)

@shanshin
Copy link
Collaborator

shanshin commented Mar 28, 2024

for now the only way is to use koverBinaryReport tasks to generate binary ic report and then merge them by Kover CLI.

@shanshin
Copy link
Collaborator

I think you may close this issue and track this, because there will be a discussion of the same question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Support request issue type S: in progress Status: implementing or design in process
Projects
None yet
Development

No branches or pull requests

2 participants