addVariant

abstract fun addVariant(name: String, action: Action<in VariantMetadata>)(source)

Add a rule for adding a new empty variant to the component.

Since

6.0

Parameters

name

a name for the variant

action

the action to populate the variant


abstract fun addVariant(name: String, base: String, action: Action<in VariantMetadata>)(source)

Add a rule for adding a new variant to the component. The new variant will be based on an existing variant or configurations of the component and initialized with the same attributes, capabilities, dependencies and artifacts. These can then be modified in the given configuration action. Whether the 'base' is already a variant (with attributes) or a plain configuration (without attributes) depends on the metadata source:

  • Gradle Module Metadata: all variants defined in the metadata are available as base
  • POM Metadata: the 'compile' and 'runtime' variants with the Java ecosystem attributes are available as base
  • Ivy Metadata: all configurations defined in the metadata are available as base
Note: files (artifacts) are not initialized automatically and always need to be added through withFiles.

Since

6.0

Parameters

name

a name for the variant

base

name of the variant (pom or Gradle module metadata) or configuration (ivy.xml metadata) from which the new variant will be initialized

action

the action to populate the variant