Repository: Kotlin/binary-compatibility-validator (kotlin)

Issue:
apiDump task incompatible with configuration cache
```
FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

10 problems were found storing the configuration cache.
- Task `:detekt-api:apiDump` of type `org.gradle.api.tasks.Sync`: cannot serialize object of type 'kotlinx.validation.KotlinApiBuildTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.5/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:detekt-api:apiDump` of type `org.gradle.api.tasks.Sync`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.5/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
```

Pull request description:
Fixes #95

Patch:
diff --git a/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt b/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt
index 96c428f5..7b48672c 100644
--- a/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt
+++ b/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt
@@ -182,7 +182,7 @@ private fun Project.configureKotlinCompilation(
     val apiBuild = task<KotlinApiBuildTask>(targetConfig.apiTaskName("Build"), extension) {
         // Do not enable task for empty umbrella modules
         isEnabled =
-            apiCheckEnabled(extension) && compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } }
+            apiCheckEnabled(projectName, extension) && compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } }
         // 'group' is not specified deliberately, so it will be hidden from ./gradlew tasks
         description =
             "Builds Kotlin API for 'main' compilations of $projectName. Complementary task and shouldn't be called manually"
@@ -206,8 +206,8 @@ private fun Project.configureKotlinCompilation(
 val Project.sourceSets: SourceSetContainer
     get() = convention.getPlugin(JavaPluginConvention::class.java).sourceSets
 
-fun Project.apiCheckEnabled(extension: ApiValidationExtension): Boolean =
-    name !in extension.ignoredProjects && !extension.validationDisabled
+fun apiCheckEnabled(projectName: String, extension: ApiValidationExtension): Boolean =
+    projectName !in extension.ignoredProjects && !extension.validationDisabled
 
 private fun Project.configureApiTasks(
     sourceSet: SourceSet,
@@ -217,7 +217,7 @@ private fun Project.configureApiTasks(
     val projectName = project.name
     val apiBuildDir = targetConfig.apiDir.map { buildDir.resolve(it) }
     val apiBuild = task<KotlinApiBuildTask>(targetConfig.apiTaskName("Build"), extension) {
-        isEnabled = apiCheckEnabled(extension)
+        isEnabled = apiCheckEnabled(projectName, extension)
         // 'group' is not specified deliberately so it will be hidden from ./gradlew tasks
         description =
             "Builds Kotlin API for 'main' compilations of $projectName. Complementary task and shouldn't be called manually"
@@ -244,7 +244,7 @@ private fun Project.configureCheckTasks(
         }
     }
     val apiCheck = task<KotlinApiCompareTask>(targetConfig.apiTaskName("Check")) {
-        isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true)
+        isEnabled = apiCheckEnabled(projectName, extension) && apiBuild.map { it.enabled }.getOrElse(true)
         group = "verification"
         description = "Checks signatures of public API against the golden value in API folder for $projectName"
         run {
@@ -261,15 +261,12 @@ private fun Project.configureCheckTasks(
     }
 
     val apiDump = task<Sync>(targetConfig.apiTaskName("Dump")) {
-        isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true)
+        isEnabled = apiCheckEnabled(projectName, extension) && apiBuild.map { it.enabled }.getOrElse(true)
         group = "other"
         description = "Syncs API from build dir to ${targetConfig.apiDir} dir for $projectName"
         from(apiBuildDir)
         into(apiCheckDir)
         dependsOn(apiBuild)
-        doFirst {
-            apiCheckDir.get().mkdirs()
-        }
     }
 
     commonApiDump?.configure { it.dependsOn(apiDump) }


Test patch:
diff --git a/src/functionalTest/kotlin/kotlinx/validation/api/TestDsl.kt b/src/functionalTest/kotlin/kotlinx/validation/api/TestDsl.kt
index b88da146..16f507e2 100644
--- a/src/functionalTest/kotlin/kotlinx/validation/api/TestDsl.kt
+++ b/src/functionalTest/kotlin/kotlinx/validation/api/TestDsl.kt
@@ -132,7 +132,7 @@ internal class AppendableScope(val filePath: String) {
 }
 
 internal class Runner {
-    val arguments: MutableList<String> = mutableListOf()
+    val arguments: MutableList<String> = mutableListOf("--configuration-cache")
 }
 
 internal fun readFileList(fileName: String): String {