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

0.6.1 koverMerged not working if subproject not have an build.gradle.kts #277

Closed
comdiv opened this issue Nov 15, 2022 · 8 comments
Closed
Assignees
Labels
Bug Bug issue type S: waiting for clarification Status: additional information required to proceed

Comments

@comdiv
Copy link

comdiv commented Nov 15, 2022

We use multiproject gradle structure without build.gradle.kts in subprojects a-ka:

import kotlinx.kover.api.KoverMergedConfig

plugins {
    kotlin("jvm")  version "1.7.20" apply false
    id("org.jetbrains.kotlinx.kover") version "0.6.1"
}

repositories {
    mavenCentral()
}

subprojects {
    apply {
        plugin("org.jetbrains.kotlinx.kover")
        plugin("org.jetbrains.kotlin.jvm")
    }

    repositories {
        mavenCentral()
    }

    dependencies {
        "testImplementation"(kotlin("test"))
    }

}

// 0.6.1 equivalent
koverMerged {
    enable()
    filters {
        classes {
            includes += "org.my.*"
        }
    }
}

(in our case it's performed by our own plugin)

But it's not working if i don't have file build.gradle.kts in subproject!

It seems that it's ignores gradle project tree reflection and explicitly check existence of build.gradle.kts and includes dependent tasks based on this information.

We got this problem while migrating from 0.5.0 to 0.6.1 - where wasn't problems before

We can avoid it by hack:

afterEvaluate {
    tasks.named("koverMergedHtmlReport") {
        dependsOn(project(":p1").tasks.named("test"))
        dependsOn(project(":p2").tasks.named("test"))
    }
}

but it's looks like hack and it IS hack.

@comdiv comdiv added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Nov 15, 2022
@comdiv
Copy link
Author

comdiv commented Nov 15, 2022

In sample project this hack works but not in real project.
We change our own plugin (project template) to use this flow of applying but it still sees only projects with build.gradle.kts in it's directories...

@comdiv
Copy link
Author

comdiv commented Nov 15, 2022

The problem is that script:

import kotlinx.kover.api.KoverMergedConfig

plugins {
    kotlin("jvm")  version "1.7.20" apply false
    id("org.jetbrains.kotlinx.kover") version "0.6.1" apply false
}



repositories {
    mavenCentral()
}

subprojects {
    apply {
        plugin("org.jetbrains.kotlinx.kover")
        plugin("org.jetbrains.kotlin.jvm")
    }

    repositories {
        mavenCentral()
    }

    dependencies {
        "testImplementation"(kotlin("test"))
    }

}


apply {
    plugin("org.jetbrains.kotlinx.kover")
}
extensions.configure<KoverMergedConfig>("koverMerged") {
    enable()
    filters {
        classes {
            includes += "codes.spectrum.*"
        }
    }
}


afterEvaluate {
    tasks.named("koverMergedHtmlReport") {
        dependsOn(project(":p1").tasks.named("test"))
        dependsOn(project(":p2").tasks.named("test"))
    }
}

not working.

For the first look:

plugins {
    kotlin("jvm")  version "1.7.20" apply false
    id("org.jetbrains.kotlinx.kover") version "0.6.1"
}
koverMerged {
   ...
}

should work same way as

plugins {
    kotlin("jvm")  version "1.7.20" apply false
    id("org.jetbrains.kotlinx.kover") version "0.6.1" apply false
}
...
apply {
    plugin("org.jetbrains.kotlinx.kover")
}
extensions.configure<KoverMergedConfig>("koverMerged") {
   ....
}

but they are somehow different so we cannot use our hack form our gradle extension...

@comdiv
Copy link
Author

comdiv commented Nov 15, 2022

Maybe it's another problem - but may be you tell me how.
How to exclude nested projects a-ka :nest:dir:proj - excludes.add(":nest:dir:proj") not working (in merge config)

@shanshin
Copy link
Collaborator

Hi,

But it's not working if i don't have file build.gradle.kts in subproject!

may you clarify how exactly shown that the plugin does not work?

How to exclude nested projects a-ka :nest:dir:proj - excludes.add(":nest:dir:proj") not working (in merge config)

it is difficult to answer without a concrete example, however, an exclusion by the project path should work. The project path does not always coincide with the directory in which the project itself is located. You can try to exclude by project name rather than path.

@shanshin shanshin added S: waiting for clarification Status: additional information required to proceed and removed S: untriaged Status: issue reported but unprocessed labels Nov 15, 2022
@comdiv
Copy link
Author

comdiv commented Nov 18, 2022

Sorry, wrong about exclusion. Just first problem in game

@shanshin
Copy link
Collaborator

shanshin commented Nov 18, 2022

As a workaround try to exclude subproject without build.gradle.kts file.
E.g. if project structure is

root
    a
        without               // directory without `build.gradle.kts` file
            child

use this to exclude

koverMerged {
    enable()

    filters {
        projects {
            excludes += listOf(":a:without")
        }
    }
}

@aSemy
Copy link
Contributor

aSemy commented Dec 5, 2022

This is a consequence of the quick-fix introduced in #224. It will hopefully be fixed by #284.

Here are some more suggestions for workarounds:

  • add an empty build.gradle.kts to each of the subprojects
  • instead of using subprojects {}, instead use a buildSrc convention plugin.

@shanshin
Copy link
Collaborator

Fixed in 0.7.0-Alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: waiting for clarification Status: additional information required to proceed
Projects
None yet
Development

No branches or pull requests

3 participants