Skip to content

Commit b569f24

Browse files
authored
Restore compatibility with Gradle's configuration cache (#96)
Fixes #95
1 parent 89ad35e commit b569f24

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/functionalTest/kotlin/kotlinx/validation/api/TestDsl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ internal class AppendableScope(val filePath: String) {
132132
}
133133

134134
internal class Runner {
135-
val arguments: MutableList<String> = mutableListOf()
135+
val arguments: MutableList<String> = mutableListOf("--configuration-cache")
136136
}
137137

138138
internal fun readFileList(fileName: String): String {

src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private fun Project.configureKotlinCompilation(
182182
val apiBuild = task<KotlinApiBuildTask>(targetConfig.apiTaskName("Build"), extension) {
183183
// Do not enable task for empty umbrella modules
184184
isEnabled =
185-
apiCheckEnabled(extension) && compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } }
185+
apiCheckEnabled(projectName, extension) && compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } }
186186
// 'group' is not specified deliberately, so it will be hidden from ./gradlew tasks
187187
description =
188188
"Builds Kotlin API for 'main' compilations of $projectName. Complementary task and shouldn't be called manually"
@@ -206,8 +206,8 @@ private fun Project.configureKotlinCompilation(
206206
val Project.sourceSets: SourceSetContainer
207207
get() = convention.getPlugin(JavaPluginConvention::class.java).sourceSets
208208

209-
fun Project.apiCheckEnabled(extension: ApiValidationExtension): Boolean =
210-
name !in extension.ignoredProjects && !extension.validationDisabled
209+
fun apiCheckEnabled(projectName: String, extension: ApiValidationExtension): Boolean =
210+
projectName !in extension.ignoredProjects && !extension.validationDisabled
211211

212212
private fun Project.configureApiTasks(
213213
sourceSet: SourceSet,
@@ -217,7 +217,7 @@ private fun Project.configureApiTasks(
217217
val projectName = project.name
218218
val apiBuildDir = targetConfig.apiDir.map { buildDir.resolve(it) }
219219
val apiBuild = task<KotlinApiBuildTask>(targetConfig.apiTaskName("Build"), extension) {
220-
isEnabled = apiCheckEnabled(extension)
220+
isEnabled = apiCheckEnabled(projectName, extension)
221221
// 'group' is not specified deliberately so it will be hidden from ./gradlew tasks
222222
description =
223223
"Builds Kotlin API for 'main' compilations of $projectName. Complementary task and shouldn't be called manually"
@@ -244,7 +244,7 @@ private fun Project.configureCheckTasks(
244244
}
245245
}
246246
val apiCheck = task<KotlinApiCompareTask>(targetConfig.apiTaskName("Check")) {
247-
isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true)
247+
isEnabled = apiCheckEnabled(projectName, extension) && apiBuild.map { it.enabled }.getOrElse(true)
248248
group = "verification"
249249
description = "Checks signatures of public API against the golden value in API folder for $projectName"
250250
run {
@@ -261,15 +261,12 @@ private fun Project.configureCheckTasks(
261261
}
262262

263263
val apiDump = task<Sync>(targetConfig.apiTaskName("Dump")) {
264-
isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true)
264+
isEnabled = apiCheckEnabled(projectName, extension) && apiBuild.map { it.enabled }.getOrElse(true)
265265
group = "other"
266266
description = "Syncs API from build dir to ${targetConfig.apiDir} dir for $projectName"
267267
from(apiBuildDir)
268268
into(apiCheckDir)
269269
dependsOn(apiBuild)
270-
doFirst {
271-
apiCheckDir.get().mkdirs()
272-
}
273270
}
274271

275272
commonApiDump?.configure { it.dependsOn(apiDump) }

0 commit comments

Comments
 (0)