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

Merged report with allProjects/subProjects fails if there is an empty project #706

Closed
utikeev opened this issue Nov 21, 2024 · 7 comments
Closed
Assignees
Labels
Bug Bug issue type S: untriaged Status: issue reported but unprocessed

Comments

@utikeev
Copy link

utikeev commented Nov 21, 2024

Describe the bug
If the multi-module project has an empty project that serves only as an aggregate for several subprojects, the merge use-case becomes inconvenient to use.
a) it creates empty build folders in such empty projects with kover/.artifact
b) it fails the build if repositories aren't configured in those empty projects

There is a workaround to apply dependency management on the build level in settings.gradle.kts, but as it is an incubating feature, it'd be good if it was possible without that.

Errors

   > Cannot resolve external dependency org.jetbrains.kotlinx:kover-jvm-agent:0.8.3 because no repositories are defined.
     Required by:
         project :data

Expected behavior
Empty projects should be skipped when merging.

Reproducer
https://github.com/utikeev/kover-merge-issue
Try calling ./gradlew koverBinaryReport.

Environment

  • Kover Gradle Plugin version: 0.8.3
  • Gradle version: 8.10
  • Kotlin project type: Kotlin/JVM
  • Coverage Toolset (if customized in build script): isn't customized

Notes
While I understand that the merge use-case is considered delicate and is not a recommended approach, it feels weird not to have a shortcut to easily merge coverage from all the projects included in the root build. Effectively duplicating the list of submodules that needs to be covered inside a merging module looks error-prone as now you've got to support two lists of submodules.
As far as I understand, the experimental aggregated plugin is going to solve just that but feel free to correct me if I'm wrong here.

@utikeev utikeev added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Nov 21, 2024
@shanshin
Copy link
Collaborator

Hi,
to skip projects that do not need to be covered, please explicitly specify this projects

e.g.

kover {
    merge {
        subprojects {
            // merge all project except :data
            it.path != ":data"
        }
    }
}

@utikeev
Copy link
Author

utikeev commented Nov 21, 2024

But what if I have tens of such subprojects? This solution doesn't scale well.

@shanshin
Copy link
Collaborator

What criteria do you use to describe an empty project, no source code files?

@shanshin
Copy link
Collaborator

Any static criteria can be used in filtering, for example

kover {
    merge {
        subprojects {
            // apply Kover only if src directory exists in subproject directory
            it.layout.projectDirectory.dir("src").asFile.exists()
        }
    }
}

@utikeev
Copy link
Author

utikeev commented Nov 21, 2024

I guess it can rely on the presence of the Kotlin plugin(s) in the subproject. Is there a point in applying the plugin to a non-Kotlin project?

@shanshin
Copy link
Collaborator

I guess it can rely on the presence of the Kotlin plugin(s) in the subproject. Is there a point in applying the plugin to a non-Kotlin project?

It is for this reason that it is not recommended to use the allprojects approach (used in merge).

  • the root project is evaluated before subprojects are evaluated
  • decide whether to apply Kover plugin is necessary to decide before calculating the subproject so that the DSL is generated (to be able to write kover { ... } in build script files)
  • when applying the plugin, a configuration is created from which the kover-jvm-agent dependency will be resolved
  • Kotlin plugin is applied at the time of subproject evaluation, which is obvious later than the time of deciding whether to apply Kover plugin

So the conclusion is that with this approach it is necessary to write a filter that will be guided by the information that is available before the evaluation of a subproject.

We can focus on indirect signs, such as the presence of the src directory, as in the example above.

@shanshin
Copy link
Collaborator

In general, the problem cannot be solved universally.
This problem is specific only to separate Kotlin Gradle Plugin, after implementation of #608 such a problem will not exist.

@shanshin shanshin closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: untriaged Status: issue reported but unprocessed
Projects
None yet
Development

No branches or pull requests

2 participants