@@ -83,8 +83,9 @@ private fun Project.configureKotlinCompilation(
83
83
val projectName = project.name
84
84
val apiBuildDir = file(buildDir.resolve(API_DIR ))
85
85
val apiBuild = task<KotlinApiBuildTask >(" apiBuild" , extension) {
86
- // Do not enable task for empty umbrella modules
87
- isEnabled = apiCheckEnabled(extension) && compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } }
86
+ // Do not execute task for empty umbrella modules
87
+ onlyIf { compilation.allKotlinSourceSets.any { it.kotlin.srcDirs.any { it.exists() } } }
88
+ isEnabled = apiCheckEnabled(extension)
88
89
// 'group' is not specified deliberately so it will be hidden from ./gradlew tasks
89
90
description =
90
91
" Builds Kotlin API for 'main' compilations of $projectName . Complementary task and shouldn't be called manually"
@@ -131,7 +132,9 @@ private fun Project.configureCheckTasks(
131
132
val projectName = project.name
132
133
val apiCheckDir = file(projectDir.resolve(API_DIR ))
133
134
val apiCheck = task<ApiCompareCompareTask >(" apiCheck" ) {
134
- isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true )
135
+ // Do not execute task for empty umbrella modules
136
+ onlyIf { apiBuild.get().isOnlyIf() }
137
+ isEnabled = apiCheckEnabled(extension)
135
138
group = " verification"
136
139
description = " Checks signatures of public API against the golden value in API folder for $projectName "
137
140
projectApiDir = if (apiCheckDir.exists()) {
@@ -145,7 +148,9 @@ private fun Project.configureCheckTasks(
145
148
}
146
149
147
150
task<Sync >(" apiDump" ) {
148
- isEnabled = apiCheckEnabled(extension) && apiBuild.map { it.enabled }.getOrElse(true )
151
+ // Do not execute task for empty umbrella modules
152
+ onlyIf { apiBuild.get().isOnlyIf() }
153
+ isEnabled = apiCheckEnabled(extension)
149
154
group = " other"
150
155
description = " Syncs API from build dir to $API_DIR dir for $projectName "
151
156
from(apiBuildDir)
@@ -158,6 +163,8 @@ private fun Project.configureCheckTasks(
158
163
project.tasks.getByName(" check" ).dependsOn(apiCheck)
159
164
}
160
165
166
+ private fun KotlinApiBuildTask.isOnlyIf (): Boolean = onlyIf.isSatisfiedBy(this )
167
+
161
168
inline fun <reified T : Task > Project.task (
162
169
name : String ,
163
170
noinline configuration : T .() -> Unit
0 commit comments