@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.gradle.plugin.*
17
17
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
18
18
import org.jetbrains.kotlin.konan.target.HostManager
19
19
import org.jetbrains.kotlin.library.abi.ExperimentalLibraryAbiReader
20
- import org.jetbrains.kotlin.library.abi.LibraryAbiReader
21
20
import java.io.*
22
21
import java.util.*
23
22
@@ -35,7 +34,7 @@ public class BinaryCompatibilityValidatorPlugin : Plugin<Project> {
35
34
private fun Project.validateExtension (extension : ApiValidationExtension ) {
36
35
afterEvaluate {
37
36
val ignored = extension.ignoredProjects
38
- val all = allprojects.map { it.name }
37
+ val all = allprojects.map { it.path }
39
38
for (project in ignored) {
40
39
require(project in all) { " Cannot find excluded project $project in all projects: $all " }
41
40
}
@@ -55,7 +54,7 @@ public class BinaryCompatibilityValidatorPlugin : Plugin<Project> {
55
54
extension : ApiValidationExtension ,
56
55
action : Action <AppliedPlugin >
57
56
) = project.pluginManager.withPlugin(name) {
58
- if (project.name in extension.ignoredProjects) return @withPlugin
57
+ if (project.path in extension.ignoredProjects) return @withPlugin
59
58
action.execute(it)
60
59
}
61
60
@@ -64,7 +63,7 @@ public class BinaryCompatibilityValidatorPlugin : Plugin<Project> {
64
63
extension : ApiValidationExtension ,
65
64
jvmRuntimeClasspath : NamedDomainObjectProvider <Configuration >
66
65
) = configurePlugin(" kotlin-multiplatform" , project, extension) {
67
- if (project.name in extension.ignoredProjects) return @configurePlugin
66
+ if (project.path in extension.ignoredProjects) return @configurePlugin
68
67
val kotlin = project.kotlinMultiplatform
69
68
70
69
// Create common tasks for multiplatform
@@ -208,16 +207,16 @@ private fun Project.configureKotlinCompilation(
208
207
commonApiCheck : TaskProvider <Task >? = null,
209
208
useOutput : Boolean = false,
210
209
) {
211
- val projectName = project.name
210
+ val projectPath = project.path
212
211
val dumpFileName = project.jvmDumpFileName
213
212
val apiDirProvider = targetConfig.apiDir
214
213
val apiBuildDir = apiDirProvider.flatMap { f -> layout.buildDirectory.asFile.map { it.resolve(f) } }
215
214
216
215
val apiBuild = task<KotlinApiBuildTask >(targetConfig.apiTaskName(" Build" )) {
217
- isEnabled = apiCheckEnabled(projectName , extension)
216
+ isEnabled = apiCheckEnabled(projectPath , extension)
218
217
// 'group' is not specified deliberately, so it will be hidden from ./gradlew tasks
219
218
description =
220
- " Builds Kotlin API for 'main' compilations of $projectName . Complementary task and shouldn't be called manually"
219
+ " Builds Kotlin API for 'main' compilations of $projectPath . Complementary task and shouldn't be called manually"
221
220
if (useOutput) {
222
221
// Workaround for #4
223
222
inputClassesDirs.from(compilation.output.classesDirs)
@@ -240,19 +239,19 @@ internal val Project.apiValidationExtensionOrNull: ApiValidationExtension?
240
239
.map { it.extensions.findByType(ApiValidationExtension ::class .java) }
241
240
.firstOrNull { it != null }
242
241
243
- private fun apiCheckEnabled (projectName : String , extension : ApiValidationExtension ): Boolean =
244
- projectName !in extension.ignoredProjects && ! extension.validationDisabled
242
+ private fun apiCheckEnabled (projectPath : String , extension : ApiValidationExtension ): Boolean =
243
+ projectPath !in extension.ignoredProjects && ! extension.validationDisabled
245
244
246
245
@OptIn(ExperimentalBCVApi ::class )
247
- private fun klibAbiCheckEnabled (projectName : String , extension : ApiValidationExtension ): Boolean =
248
- projectName !in extension.ignoredProjects && ! extension.validationDisabled && extension.klib.enabled
246
+ private fun klibAbiCheckEnabled (projectPath : String , extension : ApiValidationExtension ): Boolean =
247
+ projectPath !in extension.ignoredProjects && ! extension.validationDisabled && extension.klib.enabled
249
248
250
249
private fun Project.configureApiTasks (
251
250
extension : ApiValidationExtension ,
252
251
targetConfig : TargetConfig = TargetConfig (this, extension),
253
252
jvmRuntimeClasspath : NamedDomainObjectProvider <Configuration >,
254
253
) {
255
- val projectName = project.name
254
+ val projectPath = project.path
256
255
val dumpFileName = project.jvmDumpFileName
257
256
val apiBuildDir = targetConfig.apiDir.flatMap { f -> layout.buildDirectory.asFile.map { it.resolve(f) } }
258
257
val sourceSetsOutputsProvider = project.provider {
@@ -262,10 +261,10 @@ private fun Project.configureApiTasks(
262
261
}
263
262
264
263
val apiBuild = task<KotlinApiBuildTask >(targetConfig.apiTaskName(" Build" )) {
265
- isEnabled = apiCheckEnabled(projectName , extension)
264
+ isEnabled = apiCheckEnabled(projectPath , extension)
266
265
// 'group' is not specified deliberately, so it will be hidden from ./gradlew tasks
267
266
description =
268
- " Builds Kotlin API for 'main' compilations of $projectName . Complementary task and shouldn't be called manually"
267
+ " Builds Kotlin API for 'main' compilations of $projectPath . Complementary task and shouldn't be called manually"
269
268
inputClassesDirs.from(sourceSetsOutputsProvider)
270
269
outputApiFile.fileProvider(apiBuildDir.map { it.resolve(dumpFileName) })
271
270
runtimeClasspath.from(jvmRuntimeClasspath)
@@ -281,25 +280,25 @@ private fun Project.configureCheckTasks(
281
280
commonApiDump : TaskProvider <Task >? = null,
282
281
commonApiCheck : TaskProvider <Task >? = null,
283
282
) {
284
- val projectName = project.name
283
+ val projectPath = project.path
285
284
val apiCheckDir = targetConfig.apiDir.map {
286
285
projectDir.resolve(it).also { r ->
287
286
logger.debug(" Configuring api for ${targetConfig.targetName ? : " jvm" } to $r " )
288
287
}
289
288
}
290
289
val apiCheck = task<KotlinApiCompareTask >(targetConfig.apiTaskName(" Check" )) {
291
- isEnabled = apiCheckEnabled(projectName , extension) && apiBuild.map { it.enabled }.getOrElse(true )
290
+ isEnabled = apiCheckEnabled(projectPath , extension) && apiBuild.map { it.enabled }.getOrElse(true )
292
291
group = " verification"
293
- description = " Checks signatures of public API against the golden value in API folder for $projectName "
292
+ description = " Checks signatures of public API against the golden value in API folder for $projectPath "
294
293
projectApiFile.fileProvider(apiCheckDir.map { it.resolve(jvmDumpFileName) })
295
294
generatedApiFile.set(apiBuild.flatMap { it.outputApiFile })
296
295
}
297
296
298
297
val dumpFileName = project.jvmDumpFileName
299
298
val apiDump = task<SyncFile >(targetConfig.apiTaskName(" Dump" )) {
300
- isEnabled = apiCheckEnabled(projectName , extension) && apiBuild.map { it.enabled }.getOrElse(true )
299
+ isEnabled = apiCheckEnabled(projectPath , extension) && apiBuild.map { it.enabled }.getOrElse(true )
301
300
group = " other"
302
- description = " Syncs the API file for $projectName "
301
+ description = " Syncs the API file for $projectPath "
303
302
from.set(apiBuild.flatMap { it.outputApiFile })
304
303
to.fileProvider(apiCheckDir.map { it.resolve(dumpFileName) })
305
304
}
@@ -398,16 +397,16 @@ private class KlibValidationPipelineBuilder(
398
397
399
398
private fun Project.checkKlibsTask (klibDumpConfig : TargetConfig ) =
400
399
project.task<KotlinApiCompareTask >(klibDumpConfig.apiTaskName(" Check" )) {
401
- isEnabled = klibAbiCheckEnabled(project.name , extension)
400
+ isEnabled = klibAbiCheckEnabled(project.path , extension)
402
401
group = " verification"
403
402
description =
404
- " Checks signatures of a public KLib ABI against the golden value in ABI folder for ${project.name } "
403
+ " Checks signatures of a public KLib ABI against the golden value in ABI folder for ${project.path } "
405
404
}
406
405
407
406
private fun Project.dumpKlibsTask (klibDumpConfig : TargetConfig ) =
408
407
project.task<SyncFile >(klibDumpConfig.apiTaskName(" Dump" )) {
409
- isEnabled = klibAbiCheckEnabled(project.name , extension)
410
- description = " Syncs the KLib ABI file for ${project.name } "
408
+ isEnabled = klibAbiCheckEnabled(project.path , extension)
409
+ description = " Syncs the KLib ABI file for ${project.path } "
411
410
group = " other"
412
411
onlyIf {
413
412
it as SyncFile
@@ -424,7 +423,7 @@ private class KlibValidationPipelineBuilder(
424
423
klibDumpConfig.apiTaskName(" ExtractForValidation" )
425
424
)
426
425
{
427
- isEnabled = klibAbiCheckEnabled(project.name , extension)
426
+ isEnabled = klibAbiCheckEnabled(project.path , extension)
428
427
description = " Prepare a reference KLib ABI file by removing all unsupported targets from " +
429
428
" the golden file stored in the project"
430
429
group = " other"
@@ -443,7 +442,7 @@ private class KlibValidationPipelineBuilder(
443
442
klibDumpConfig.apiTaskName(" MergeInferred" )
444
443
)
445
444
{
446
- isEnabled = klibAbiCheckEnabled(project.name , extension)
445
+ isEnabled = klibAbiCheckEnabled(project.path , extension)
447
446
description = " Merges multiple KLib ABI dump files generated for " +
448
447
" different targets (including inferred dumps for unsupported targets) " +
449
448
" into a single merged KLib ABI dump"
@@ -456,7 +455,7 @@ private class KlibValidationPipelineBuilder(
456
455
klibMergeDir : Provider <File >,
457
456
runtimeClasspath : NamedDomainObjectProvider <Configuration >
458
457
) = project.task<KotlinKlibMergeAbiTask >(klibDumpConfig.apiTaskName(" Merge" )) {
459
- isEnabled = klibAbiCheckEnabled(project.name , extension)
458
+ isEnabled = klibAbiCheckEnabled(project.path , extension)
460
459
description = " Merges multiple KLib ABI dump files generated for " +
461
460
" different targets into a single merged KLib ABI dump"
462
461
mergedApiFile.fileProvider(klibMergeDir.map { it.resolve(klibDumpFileName) })
@@ -577,11 +576,11 @@ private class KlibValidationPipelineBuilder(
577
576
apiBuildDir : Provider <File >,
578
577
runtimeClasspath : NamedDomainObjectProvider <Configuration >
579
578
): TaskProvider <KotlinKlibAbiBuildTask > {
580
- val projectName = project.name
579
+ val projectPath = project.path
581
580
val buildTask = project.task<KotlinKlibAbiBuildTask >(targetConfig.apiTaskName(" Build" )) {
582
- isEnabled = klibAbiCheckEnabled(projectName , extension)
581
+ isEnabled = klibAbiCheckEnabled(projectPath , extension)
583
582
// 'group' is not specified deliberately, so it will be hidden from ./gradlew tasks
584
- description = " Builds Kotlin KLib ABI dump for 'main' compilations of $projectName . " +
583
+ description = " Builds Kotlin KLib ABI dump for 'main' compilations of $projectPath . " +
585
584
" Complementary task and shouldn't be called manually"
586
585
this .target.set(target)
587
586
klibFile.from(compilation.output.classesDirs)
@@ -594,7 +593,7 @@ private class KlibValidationPipelineBuilder(
594
593
595
594
private fun Project.mergeDependencyForUnsupportedTarget (targetConfig : TargetConfig ): TaskProvider <DefaultTask > {
596
595
return project.task<DefaultTask >(targetConfig.apiTaskName(" Build" )) {
597
- isEnabled = apiCheckEnabled(project.name , extension)
596
+ isEnabled = apiCheckEnabled(project.path , extension)
598
597
599
598
doLast {
600
599
logger.warn(
@@ -613,7 +612,7 @@ private class KlibValidationPipelineBuilder(
613
612
): TaskProvider <KotlinKlibInferAbiTask > {
614
613
val targetName = targetConfig.targetName!!
615
614
return project.task<KotlinKlibInferAbiTask >(targetConfig.apiTaskName(" Infer" )) {
616
- isEnabled = klibAbiCheckEnabled(project.name , extension)
615
+ isEnabled = klibAbiCheckEnabled(project.path , extension)
617
616
description = " Try to infer the dump for unsupported target $targetName using dumps " +
618
617
" generated for supported targets."
619
618
group = " other"
0 commit comments