KotlinMultiplatformAndroidComponentsExtension

Added in 8.2.0

@Incubating
interface KotlinMultiplatformAndroidComponentsExtension : DslLifecycle, AndroidComponents


Components extension for KMP Android Gradle Plugin related components.

Summary

Public functions

Unit

Action based version of onVariant above.

Unit

Allow for registration of a callback to be called with variant instances of type KotlinMultiplatformAndroidLibraryExtension once the list of com.android.build.api.artifact.Artifact has been determined.

Inherited functions

From com.android.build.api.variant.DslLifecycle
Unit

Action based version of finalizeDsl above.

Unit

API to customize the DSL Objects programmatically after they have been evaluated from the build files and before used in the build process next steps like variant or tasks creation.

Inherited properties

From com.android.build.api.variant.AndroidComponents
AndroidPluginVersion

The version of the Android Gradle Plugin currently in use.

SdkComponents

Provides access to underlying Android SDK and build-tools components like adb.

Public functions

onVariant

Added in 8.2.0
fun onVariant(callback: Action<KotlinMultiplatformAndroidVariant>): Unit

Action based version of onVariant above.

onVariant

Added in 8.2.0
fun onVariant(callback: (KotlinMultiplatformAndroidVariant) -> Unit): Unit

Allow for registration of a callback to be called with variant instances of type KotlinMultiplatformAndroidLibraryExtension once the list of com.android.build.api.artifact.Artifact has been determined.

At this stage, access to the DSL objects is disallowed

Because the list of artifacts (including private ones) is final, one cannot change the build flow anymore as org.gradle.api.Tasks are now expecting those artifacts as inputs. However users can modify such artifacts by replacing or transforming them, see com.android.build.api.artifact.Artifacts for details.

Code executing in the callback also has access to the KotlinMultiplatformAndroidLibraryExtension information which is used to configure org.gradle.api.Task inputs (for example, the buildConfigFields). Such information represented as org.gradle.api.provider.Property can still be modified ensuring that all org.gradle.api.Tasks created by the Android Gradle Plugin use the updated value.