KotlinMultiplatformAndroidVariant

Added in 8.2.0

@Incubating
interface KotlinMultiplatformAndroidVariant : HasDeviceTests, HasAndroidTest, HasUnitTest, HasHostTests


Properties for the main Variant of a kotlin multiplatform android library

Summary

Public properties

Artifacts

Access to the variant's buildable artifacts for build customization.

FileCollection

Access to the variant's compile classpath.

Instrumentation

Access to the variant's instrumentation options.

LifecycleTasks

Provides access to the LifecycleTasks created for this component.

String

The name of the variant

List<Component>

List of the components nested in the main variant, the returned list may contain:

Sources

Inherited properties

From com.android.build.api.variant.HasAndroidTest
AndroidTest?

Variant's AndroidTest configuration, or null if android tests are disabled for this variant.

TestedComponentPackaging

Variant's packagingOptions, initialized by the corresponding global DSL element.

From com.android.build.api.variant.HasDeviceTests
Map<StringDeviceTest>

Variant's Map of DeviceTest configurations, or empty if all devices tests (like android tests) are disabled for this variant.

From com.android.build.api.variant.HasHostTests
Map<StringHostTest>

Map of Variant's HostTest, or empty if all host tests (like unit test) for this variant are disabled.

From com.android.build.api.variant.HasUnitTest
UnitTest?

Variant's UnitTest, or null if the unit tests for this variant are disabled.

Public properties

artifacts

Added in 8.2.0
val artifactsArtifacts

Access to the variant's buildable artifacts for build customization.

compileClasspath

Added in 8.2.0
val compileClasspathFileCollection

Access to the variant's compile classpath.

The returned FileCollection should not be resolved until execution time.

instrumentation

Added in 8.2.0
val instrumentationInstrumentation

Access to the variant's instrumentation options.

lifecycleTasks

Added in 8.3.1
val lifecycleTasksLifecycleTasks

Provides access to the LifecycleTasks created for this component.

name

Added in 8.2.0
val nameString

The name of the variant

nestedComponents

Added in 8.3.1
val nestedComponentsList<Component>

List of the components nested in the main variant, the returned list may contain:

  • UnitTest component if the unit tests for this variant are enabled,

  • AndroidTest component if this variant HasDeviceTests and android tests for this variant are enabled,

Use this list to do operations on all nested components of this variant without having to manually check whether the variant has each component.

Example:

androidComponents {
onVariant { variant ->
variant.nestedComponents.forEach { component ->
component.instrumentation.transformClassesWith(
AsmClassVisitorFactoryImpl.class,
InstrumentationScope.Project) { params -> params.x = "value" }
instrumentation.setAsmFramesComputationMode(COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS)
}
}
}

sources

Added in 8.9.0-alpha03
val sourcesSources