Skip to content

Commit

Permalink
Removed checking of parent projects for re-apply of the plugin
Browse files Browse the repository at this point in the history
Checking parent projects causes a deadlock when projects are deeply nested.
Fixes #116
  • Loading branch information
shanshin committed Jan 21, 2022
1 parent 8c8055b commit fa907c7
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/main/kotlin/kotlinx/kover/KoverPlugin.kt
Expand Up @@ -39,8 +39,6 @@ class KoverPlugin : Plugin<Project> {
private val defaultJacocoVersion = "0.8.7"

override fun apply(target: Project) {
target.checkAlreadyApplied()

val koverExtension = target.createKoverExtension()
val agents = AgentsFactory.createAgents(target, koverExtension)

Expand Down Expand Up @@ -210,6 +208,10 @@ class KoverPlugin : Plugin<Project> {
projectProviders: ProjectProviders,
block: (T) -> Unit
): T {
tasks.findByName(taskName)?.let {
throw GradleException("Kover task '$taskName' already exist. Plugin should not be applied in child project if it has already been applied in one of the parent projects.")
}

return tasks.create(taskName, type.java) { task ->
task.group = VERIFICATION_GROUP

Expand Down Expand Up @@ -265,17 +267,6 @@ class KoverPlugin : Plugin<Project> {

doLast(IntellijErrorLogChecker(taskExtension))
}

private fun Project.checkAlreadyApplied() {
var parent = parent

while (parent != null) {
if (parent.plugins.hasPlugin(KoverPlugin::class.java)) {
throw GradleException("Kover plugin is applied in both parent project '${parent.name}' and child project '${this.name}'. Kover plugin should be applied only in parent project.")
}
parent = this.parent
}
}
}

private class IntellijErrorLogChecker(private val taskExtension: KoverTaskExtension) : Action<Task> {
Expand Down

0 comments on commit fa907c7

Please sign in to comment.