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

Multiproject shortcuts #466

Closed
shanshin opened this issue Sep 21, 2023 · 3 comments · Fixed by #549
Closed

Multiproject shortcuts #466

shanshin opened this issue Sep 21, 2023 · 3 comments · Fixed by #549
Assignees
Labels
Feature Feature request issue type S: in progress Status: implementing or design in process

Comments

@shanshin
Copy link
Collaborator

Motivation

Now, in order to apply and configure the plugin in all subprojects, you need to write a special code that you need to get to, or find in the documentation.
Also, this code cannot be placed in quickstart, because it is quite large.

val rootProject = project

allprojects {
    apply("org.jetbrains.kotlinx.kover")
    
    rootProject.dependencies.add("kover", project(path))
    
    kover {
        useJacoco()
    }
}

Solution

Introduce special function for apply Kover Plugin in subprojects

for kts script

// for all projects in build
koverApply {
    useJacoco.set(true)

    // also
    disabled.set(false)
    jacocoVersion.set("0.8.8")
    excludeJavaCode.set(false)
    excludeInstrumentation { ... }
}

// for current and specified projects
koverApply(":impl", ":extra") {
    ...
}

// for all projects in build except specified
koverApply(exceptions = setOf(":api", ":util")) {
    ...
}

for Groovy

kotlinx.kover.gradle.plugin.dsl.Shortcuts.koverApply {
    ...
}
@shanshin shanshin added Feature Feature request issue type S: in progress Status: implementing or design in process labels Sep 21, 2023
@shanshin shanshin self-assigned this Sep 21, 2023
shanshin added a commit that referenced this issue Feb 23, 2024
Added shortcut for creating merged reports:
```
kover {
    merge {
        // merge configs
    }
}
```

Resolves #466
shanshin added a commit that referenced this issue Feb 29, 2024
Added shortcut for creating merged reports:

Improvements:
- added `disable()` function to Kover extension
- `variants` block renamed to `currentProject`
- `create`, `provided`, `total` blocks inside `currentProject` are renamed to `createVariant`, `providedVariant`, `totalVariant`
- instrumentation is now configured only for the project, but not for the variant
- added disabling the instrumentation of all project test tasks
- returned name `KoverProjectExtension` to Kover extension
- returned names `minValue` and `maxValue` to the bound properties
- now test tasks can be excluded only for whole project, and these tasks also won't be instrumented
- added missed deprecations

Resolves #466
PR #549
@shanshin
Copy link
Collaborator Author

Implemented in 0.8.0-Beta.
This is not a production ready release, the plugin DSL is experimental and can be changed after receiving feedback.

@mgroth0
Copy link

mgroth0 commented Jun 27, 2024

It seems like this involves cross-project configuration. Shouldn't this be discouraged in the spirit of project isolation, which newer gradle versions are gravitating towards?

But I could be wrong. I'm not too sure about how project isolation works. Maybe there is an exception with configuring sub projects from the root project.

@shanshin
Copy link
Collaborator Author

Shouldn't this be discouraged in the spirit of project isolation, which newer gradle versions are gravitating towards?

Yes, using merge { ... } block is incompatible with the project isolation. This is explicitly stated in the documentation, first of all these shortcuts are intended for those who do not use the project isolation and have already had a similar subprojects { ... } code.

Another way to solve this problem is currently being prototyped.

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

Successfully merging a pull request may close this issue.

2 participants