diff --git a/gradle.properties b/gradle.properties index bc85d7e1..d957921d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=0.4.0-SNAPSHOT +version=0.4.0.mysugr.2 group=org.jetbrains.kotlinx kotlinVersion=1.4.30 diff --git a/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt b/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt index 7bf2ddd8..ca6219cf 100644 --- a/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt +++ b/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt @@ -83,8 +83,9 @@ private fun Project.configureKotlinCompilation( val projectName = project.name val apiBuildDir = file(buildDir.resolve(API_DIR)) val apiBuild = task("apiBuild", extension) { - // Do not enable task for empty umbrella modules - isEnabled = apiCheckEnabled(extension) && compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } } + // Do not execute task for empty umbrella modules + onlyIf { compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } } } + isEnabled = apiCheckEnabled(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" @@ -131,7 +132,9 @@ private fun Project.configureCheckTasks( val projectName = project.name val apiCheckDir = file(projectDir.resolve(API_DIR)) val apiCheck = task("apiCheck") { - isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true) + // Do not execute task for empty umbrella modules + onlyIf { apiBuild.get().isOnlyIf() } + isEnabled = apiCheckEnabled(extension) group = "verification" description = "Checks signatures of public API against the golden value in API folder for $projectName" projectApiDir = if (apiCheckDir.exists()) { @@ -145,7 +148,9 @@ private fun Project.configureCheckTasks( } task("apiDump") { - isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true) + // Do not execute task for empty umbrella modules + onlyIf { apiBuild.get().isOnlyIf() } + isEnabled = apiCheckEnabled(extension) group = "other" description = "Syncs API from build dir to $API_DIR dir for $projectName" from(apiBuildDir) @@ -158,6 +163,8 @@ private fun Project.configureCheckTasks( project.tasks.getByName("check").dependsOn(apiCheck) } +private fun KotlinApiBuildTask.isOnlyIf(): Boolean = onlyIf.isSatisfiedBy(this) + inline fun Project.task( name: String, noinline configuration: T.() -> Unit