Description
Currently BCV uses vars for configuring behaviour.
This causes issues when configuring BCV, as the order of operations is now very sensitive to the order of configuration, and the interaction with different plugins. It also means that values must be computed lazily.
Lazy values also means that afterEvaluate {}
can be avoided, which can also cause compatibility issues with other Gradle plugins, and should be avoided.
In order for BCV to follow best practices, properties that are compatible with the Gradle Provider API should be used instead.
For example:
-
FileCollection
should be replaced withConfigurableFileCollection
-
Primitive properties, like
Boolean
, should be replaced withProperty<Boolean>
Conventional values
Currently, the conventions for the non-lazy properties are configured in-place.
The Provider API allows for setting default conventions, and these should be set in the BinaryCompatibilityValidatorPlugin.
For example:
override fun apply(target: Project): Unit = with(target) {
val extension = extensions.create("apiValidation", ApiValidationExtension::class.java)
extension.apply {
klib.enabled.convention(false)
}
}
Further reading: