Skip to content

Commit

Permalink
Fix breaking configuration cache
Browse files Browse the repository at this point in the history
Usage of DependencyResolutionListener is incompatible with the configuration cache, therefore, a quick solution is to remove the listener.
In the future, checking for apply of the Kover Gradle Plugin in dependencies must be done in a different way. See #537

Fixes #513
PR #538
  • Loading branch information
shanshin authored Feb 15, 2024
1 parent e8ffbda commit 56f8fd5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package kotlinx.kover.gradle.plugin.test.functional.cases
import kotlinx.kover.gradle.plugin.test.functional.framework.checker.checkNoAndroidSdk
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.buildFromTemplate
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.runWithParams
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import kotlin.test.assertContains
import kotlin.test.assertFalse

/**
* Tests on dependency check https:/Kotlin/kotlinx-kover/issues/478.
*
* Temporary disabled
*/
@Disabled
class NoDependencyTests {
@Test
fun testJvmNotApplied() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class KoverGradlePlugin : Plugin<Project> {
val applier = ProjectApplier(target)
applier.onApply()

target.addDependencyListener()
target.addDeprecations()
}

Expand All @@ -55,18 +54,4 @@ class KoverGradlePlugin : Plugin<Project> {
this.extensions.create<KoverTaskExtension>("kover")
}
}

private fun Project.addDependencyListener() {
/*
The plugin is applied for each project, but different projects in the same build have the same `gradle` object
In order not to add the listener again, it is necessary to check whether we added it earlier.
The most reliable way is to use the extra properties extension,
because it is always present and tied to a specific instance of the `Gradle`.
*/
if (gradle.extraProperties.properties[LISTENER_ADDED_PROPERTY_NAME] == null) {
gradle.extraProperties.properties[LISTENER_ADDED_PROPERTY_NAME] = true
gradle.addListener(DependencyCheckListener())
}
}
}

0 comments on commit 56f8fd5

Please sign in to comment.