For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

maybeAddVariant

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

This is the lenient version of addVariant. The only difference is that this will do nothing (instead of throwing an error), if the 'base' variant does not exist for a component. This is particularly useful for rules that are applied to all components.

Since

6.1

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