Skip to content

Commit 7d5c4ca

Browse files
committed
change strict klib validation so it's not configurable per target, but per project
1 parent 04fb1d8 commit 7d5c4ca

File tree

7 files changed

+35
-16
lines changed

7 files changed

+35
-16
lines changed

modules/bcv-gradle-plugin/api/bcv-gradle-plugin.api

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
public abstract class dev/adamko/kotlin/binary_compatibility_validator/BCVKLibConventions : dev/adamko/kotlin/binary_compatibility_validator/targets/KLibValidationSpec {
2+
public fun <init> ()V
3+
public abstract fun getStrictValidation ()Lorg/gradle/api/provider/Property;
4+
}
5+
16
public abstract class dev/adamko/kotlin/binary_compatibility_validator/BCVPlugin : org/gradle/api/Plugin {
27
public static final field API_CHECK_TASK_NAME Ljava/lang/String;
38
public static final field API_DIR Ljava/lang/String;
@@ -158,6 +163,7 @@ public abstract class dev/adamko/kotlin/binary_compatibility_validator/tasks/BCV
158163
public abstract fun getOutputApiBuildDir ()Lorg/gradle/api/file/DirectoryProperty;
159164
public abstract fun getProjectName ()Lorg/gradle/api/provider/Property;
160165
public abstract fun getRuntimeClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
166+
public abstract fun getStrictKLibTargetValidation ()Lorg/gradle/api/provider/Property;
161167
public final fun getTargets ()Lorg/gradle/api/NamedDomainObjectContainer;
162168
}
163169

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package dev.adamko.kotlin.binary_compatibility_validator
2+
3+
import dev.adamko.kotlin.binary_compatibility_validator.internal.BCVExperimentalApi
4+
import dev.adamko.kotlin.binary_compatibility_validator.targets.KLibValidationSpec
5+
import org.gradle.api.provider.Property
6+
7+
@OptIn(BCVExperimentalApi::class)
8+
abstract class BCVKLibConventions : KLibValidationSpec {
9+
10+
/**
11+
* Fail validation if some build targets are not supported by the host compiler.
12+
*
13+
* By default, ABI dumped only for supported files will be validated. This option makes
14+
* validation behavior stricter and treats having unsupported targets as an error.
15+
*/
16+
abstract val strictValidation: Property<Boolean>
17+
}

modules/bcv-gradle-plugin/src/main/kotlin/BCVProjectExtension.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dev.adamko.kotlin.binary_compatibility_validator
33
import dev.adamko.kotlin.binary_compatibility_validator.internal.*
44
import dev.adamko.kotlin.binary_compatibility_validator.targets.BCVTarget
55
import dev.adamko.kotlin.binary_compatibility_validator.targets.BCVTargetBaseSpec
6-
import dev.adamko.kotlin.binary_compatibility_validator.targets.KLibValidationSpec
76
import javax.inject.Inject
87
import org.gradle.api.file.DirectoryProperty
98
import org.gradle.api.model.ObjectFactory
@@ -46,9 +45,9 @@ constructor(
4645
abstract override val ignoredClasses: SetProperty<String>
4746

4847
@BCVExperimentalApi
49-
val klib: KLibValidationSpec =
48+
val klib: BCVKLibConventions =
5049
extensions.adding("klib") {
51-
objects.newInstance(KLibValidationSpec::class)
50+
objects.newInstance(BCVKLibConventions::class)
5251
}
5352

5453
/**

modules/bcv-gradle-plugin/src/main/kotlin/BCVProjectPlugin.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ constructor(
100100
enabled.convention(extension.klib.enabled)
101101

102102
signatureVersion.convention(extension.klib.signatureVersion)
103-
strictValidation.convention(extension.klib.strictValidation)
103+
// strictValidation.convention(extension.klib.strictValidation)
104104
supportedByCurrentHost.convention(false)
105105
}
106106

@@ -179,6 +179,9 @@ constructor(
179179
outputApiBuildDir.convention(layout.buildDirectory.dir("bcv-api"))
180180
projectName.convention(extension.projectName)
181181

182+
@OptIn(BCVExperimentalApi::class)
183+
strictKLibTargetValidation.convention(extension.klib.strictValidation)
184+
182185
onlyIf("Must have at least one target") { targets.isNotEmpty() }
183186
}
184187

modules/bcv-gradle-plugin/src/main/kotlin/targets/BCVTargetDefaults.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.adamko.kotlin.binary_compatibility_validator.targets
22

3+
import dev.adamko.kotlin.binary_compatibility_validator.BCVKLibConventions
34
import dev.adamko.kotlin.binary_compatibility_validator.internal.BCVExperimentalApi
45
import dev.adamko.kotlin.binary_compatibility_validator.internal.BCVInternalApi
56
import dev.adamko.kotlin.binary_compatibility_validator.internal.adding
@@ -43,8 +44,8 @@ constructor(
4344
abstract override val ignoredClasses: SetProperty<String>
4445

4546
@BCVExperimentalApi
46-
val klib: KLibValidationSpec =
47+
val klib: BCVKLibConventions =
4748
extensions.adding("klib") {
48-
objects.newInstance(KLibValidationSpec::class)
49+
objects.newInstance(BCVKLibConventions::class)
4950
}
5051
}

modules/bcv-gradle-plugin/src/main/kotlin/targets/KLibValidationSpec.kt

-10
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,4 @@ interface KLibValidationSpec {
4242
*/
4343
fun signatureVersion(version: Int): Unit =
4444
signatureVersion.set(KLibSignatureVersion.of(version))
45-
46-
/**
47-
* Fail validation if some build targets are not supported by the host compiler.
48-
*
49-
* By default, ABI dumped only for supported files will be validated. This option makes
50-
* validation behavior stricter and treats having unsupported targets as an error.
51-
*/
52-
@get:Input
53-
@get:Optional
54-
val strictValidation: Property<Boolean>
5545
}

modules/bcv-gradle-plugin/src/main/kotlin/tasks/BCVApiGenerateTask.kt

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ constructor(
4444
@get:Input
4545
abstract val projectName: Property<String>
4646

47+
@get:Input
48+
abstract val strictKLibTargetValidation: Property<Boolean>
49+
4750
/**
4851
* A directory containing a copy of any currently existing API Dump files.
4952
* Provided by [BCVApiGeneratePreparationTask].

0 commit comments

Comments
 (0)