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

Removed checking of parent projects for re-apply of the plugin #124

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 4 additions & 13 deletions src/main/kotlin/kotlinx/kover/KoverPlugin.kt
Original file line number Diff line number Diff line change
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