Kotlin / binary-compatibility-validator

Public API management tool
Apache License 2.0
800 stars 59 forks source link

Use the Gradle Provider API to allow for lazy configuration #207

Closed aSemy closed 1 month ago

aSemy commented 6 months ago

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:

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:

fzhinkin commented 6 months ago

@aSemy thanks for opening the issue!

As of Klib-related tasks, (almost) everything should be fixed with #204.

For old JVM-related tasks, we'll probably have to gradually deprecate and remove them and provide new "better" tasks as a replacements.