Skip to content

Commit

Permalink
Added already applied check
Browse files Browse the repository at this point in the history
  • Loading branch information
shanshin committed Dec 20, 2021
1 parent d5b27b8 commit d5e09de
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/kotlin/kotlinx/kover/KoverPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ 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 @@ -263,6 +265,17 @@ class KoverPlugin : Plugin<Project> {

return taskExtension
}

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

while (parent != null) {
if (parent.plugins.hasPlugin(KoverPlugin::class.java)) {
throw GradleException("Kover plugin already applied: in module '${parent.name}' and child module '${this.name}'")
}
parent = this.parent
}
}
}

private class CoverageArgumentProvider(
Expand Down

0 comments on commit d5e09de

Please sign in to comment.