@@ -304,7 +304,7 @@ private fun Project.configureCheckTasks(
304
304
}
305
305
306
306
val dumpFileName = project.jvmDumpFileName
307
- val apiDump = task<CopyFile >(targetConfig.apiTaskName(" Dump" )) {
307
+ val apiDump = task<SyncFile >(targetConfig.apiTaskName(" Dump" )) {
308
308
isEnabled = apiCheckEnabled(projectName, extension) && apiBuild.map { it.enabled }.getOrElse(true )
309
309
group = " other"
310
310
description = " Syncs API from build dir to ${targetConfig.apiDir} dir for $projectName "
@@ -343,7 +343,7 @@ private const val KLIB_INFERRED_DUMPS_DIRECTORY = "klib-all"
343
343
* Here's how different tasks depend on each other:
344
344
* - `klibApiCheck` ([KotlinApiCompareTask]) depends on `klibApiMerge` and `klibApiExtractForValidation` tasks;
345
345
* this task itself does not perform anything except comparing the result of a merge, with a preprocessed golden value;
346
- * - `klibApiDump` ([CopyFile ]) depends on `klibApiMergeInferred` and simply moves the merged ABI dump into a configured
346
+ * - `klibApiDump` ([SyncFile ]) depends on `klibApiMergeInferred` and simply moves the merged ABI dump into a configured
347
347
* api directory within a project;
348
348
* - `klibApiMerge` and `klibApiMergeInferred` are both [KotlinKlibMergeAbiTask] instances merging multiple individual
349
349
* KLib ABI dumps into a single merged dump file; these tasks differs only by their dependencies and input dump files
@@ -387,51 +387,36 @@ private class KlibValidationPipelineBuilder(
387
387
val klibMergeInferred = project.mergeInferredKlibsUmbrellaTask(klibDumpConfig, klibMergeInferredDir)
388
388
val klibDump = project.dumpKlibsTask(klibDumpConfig)
389
389
val klibExtractAbiForSupportedTargets = project.extractAbi(klibDumpConfig, klibApiDir, klibExtractedFileDir)
390
- val klibCheck = project.checkKlibsTask(klibDumpConfig, project.provider { klibExtractedFileDir }, klibMergeDir )
390
+ val klibCheck = project.checkKlibsTask(klibDumpConfig)
391
391
klibDump.configure {
392
392
it.from.set(klibMergeInferred.flatMap { it.mergedApiFile })
393
393
val filename = project.klibDumpFileName
394
394
it.to.fileProvider(klibApiDir.map { it.resolve(filename) })
395
395
}
396
- commonApiDump.configure { it.dependsOn(klibDump) }
397
-
398
- klibDump.configure { it.dependsOn(klibMergeInferred) }
399
- // Extraction task depends on supportedTargets() provider which returns a set of targets supported
400
- // by the host compiler and having some sources. A set of sources for a target may change until the actual
401
- // klib compilation will take place, so we may observe incorrect value if check source sets earlier.
402
- // Merge task already depends on compilations, so instead of adding each compilation task to the extraction's
403
- // dependency set, we can depend on the merge task itself.
404
- klibExtractAbiForSupportedTargets.configure {
405
- it.dependsOn(klibMerge)
406
- }
407
396
klibCheck.configure {
408
- it.dependsOn(klibExtractAbiForSupportedTargets)
397
+ it.projectApiFile.set(klibExtractAbiForSupportedTargets.flatMap { it.outputAbiFile })
398
+ it.generatedApiFile.set(klibMerge.flatMap { it.mergedApiFile })
409
399
}
400
+ commonApiDump.configure { it.dependsOn(klibDump) }
410
401
commonApiCheck.configure { it.dependsOn(klibCheck) }
411
402
project.configureTargets(klibApiDir, klibMerge, klibMergeInferred)
412
403
}
413
404
414
- private fun Project.checkKlibsTask (
415
- klibDumpConfig : TargetConfig ,
416
- klibApiDir : Provider <File >,
417
- klibMergeDir : File
418
- ) = project.task<KotlinApiCompareTask >(klibDumpConfig.apiTaskName(" Check" )) {
405
+ private fun Project.checkKlibsTask (klibDumpConfig : TargetConfig )
406
+ = project.task<KotlinApiCompareLazyTask >(klibDumpConfig.apiTaskName(" Check" )) {
419
407
isEnabled = klibAbiCheckEnabled(project.name, extension)
420
408
group = " verification"
421
- description = " Checks signatures of a public KLib ABI against the golden value in ABI folder for " +
422
- project.name
423
- projectApiFile = klibApiDir.get().resolve(klibDumpFileName)
424
- generatedApiFile = klibMergeDir.resolve(klibDumpFileName)
425
- val hasCompilableTargets = project.hasCompilableTargetsPredicate()
426
- onlyIf(" There are no klibs compiled for the project" ) { hasCompilableTargets.get() }
409
+ description = " Checks signatures of a public KLib ABI against the golden value in ABI folder for ${project.name} "
427
410
}
428
411
429
- private fun Project.dumpKlibsTask (klibDumpConfig : TargetConfig ) = project.task<CopyFile >(klibDumpConfig.apiTaskName(" Dump" )) {
412
+ private fun Project.dumpKlibsTask (klibDumpConfig : TargetConfig ) = project.task<SyncFile >(klibDumpConfig.apiTaskName(" Dump" )) {
430
413
isEnabled = klibAbiCheckEnabled(project.name, extension)
431
414
description = " Syncs a KLib ABI dump from a build dir to the ${klibDumpConfig.apiDir} dir for ${project.name} "
432
415
group = " other"
433
- val hasCompilableTargets = project.hasCompilableTargetsPredicate()
434
- onlyIf(" There are no klibs compiled for the project" ) { hasCompilableTargets.get() }
416
+ onlyIf {
417
+ it as SyncFile
418
+ it.to.get().asFile.exists() || it.from.get().asFile.exists()
419
+ }
435
420
}
436
421
437
422
private fun Project.extractAbi (
@@ -450,8 +435,6 @@ private class KlibValidationPipelineBuilder(
450
435
requiredTargets.addAll(supportedTargets())
451
436
inputAbiFile.set(klibApiDir.get().resolve(klibDumpFileName))
452
437
outputAbiFile.set(klibOutputDir.resolve(klibDumpFileName))
453
- val hasCompilableTargets = project.hasCompilableTargetsPredicate()
454
- onlyIf(" There are no klibs compiled for the project" ) { hasCompilableTargets.get() }
455
438
}
456
439
457
440
private fun Project.mergeInferredKlibsUmbrellaTask (
@@ -466,8 +449,6 @@ private class KlibValidationPipelineBuilder(
466
449
" different targets (including inferred dumps for unsupported targets) " +
467
450
" into a single merged KLib ABI dump"
468
451
mergedApiFile.set(klibMergeDir.resolve(klibDumpFileName))
469
- val hasCompilableTargets = project.hasCompilableTargetsPredicate()
470
- onlyIf(" There are no dumps to merge" ) { hasCompilableTargets.get() }
471
452
}
472
453
473
454
private fun Project.mergeKlibsUmbrellaTask (
@@ -478,8 +459,6 @@ private class KlibValidationPipelineBuilder(
478
459
description = " Merges multiple KLib ABI dump files generated for " +
479
460
" different targets into a single merged KLib ABI dump"
480
461
mergedApiFile.set(klibMergeDir.resolve(klibDumpFileName))
481
- val hasCompilableTargets = project.hasCompilableTargetsPredicate()
482
- onlyIf(" There are no dumps to merge" ) { hasCompilableTargets.get() }
483
462
}
484
463
485
464
fun Project.bannedTargets (): Set <String > {
@@ -597,8 +576,6 @@ private class KlibValidationPipelineBuilder(
597
576
val buildTask = project.task<KotlinKlibAbiBuildTask >(targetConfig.apiTaskName(" Build" )) {
598
577
// Do not enable task for empty umbrella modules
599
578
isEnabled = klibAbiCheckEnabled(projectName, extension)
600
- val hasSourcesPredicate = compilation.hasAnySourcesPredicate()
601
- onlyIf { hasSourcesPredicate.get() }
602
579
// 'group' is not specified deliberately, so it will be hidden from ./gradlew tasks
603
580
description = " Builds Kotlin KLib ABI dump for 'main' compilations of $projectName . " +
604
581
" Complementary task and shouldn't be called manually"
0 commit comments