Skip to content

Commit

Permalink
Restore compatibility with Gradle's configuration cache (#96)
Browse files Browse the repository at this point in the history
Fixes #95
  • Loading branch information
3flex committed Aug 31, 2022
1 parent 89ad35e commit b569f24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 6 additions & 9 deletions src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand All @@ -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 {
Expand All @@ -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) }
Expand Down

0 comments on commit b569f24

Please sign in to comment.