# Interface AdhocComponentWithVariants

All Superinterfaces:
  `Named, SoftwareComponent`

public interface AdhocComponentWithVariants extends SoftwareComponent
A component which can declare additional variants corresponding to features. When published to Maven POMs, the dependencies of those variants are exposed as optional dependencies. When published to Gradle metadata, the variants are published as is.

Since:
  5.3

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Named

  `Named.Namer`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addVariantsFromConfiguration(Configuration outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)`
  Declares an additional variant to publish, corresponding to an additional feature.
  `void`
  `addVariantsFromConfiguration(Provider<ConsumableConfiguration> outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)`
  Declares an additional variant to publish, corresponding to an additional feature.
  `void`
  `withVariantsFromConfiguration(Configuration outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)`
  Further configure previously declared variants.
  `void`
  `withVariantsFromConfiguration(Provider<ConsumableConfiguration> outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)`
  Further configure previously declared variants.

  ### Methods inherited from interface Named

  `getName`

- ## Method Details

  - ### addVariantsFromConfiguration

    void addVariantsFromConfiguration(Configuration outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)
    Declares an additional variant to publish, corresponding to an additional feature.

    This can be used to determine if the variant should be published or not, and to configure various options specific to the publishing format.

    Parameters:
      `outgoingConfiguration` - the configuration corresponding to the variant to use as source of dependencies and artifacts
      `action` - action executed to configure the variant prior to publishing

  - ### addVariantsFromConfiguration

    @Incubating void addVariantsFromConfiguration(Provider<ConsumableConfiguration> outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)
    Declares an additional variant to publish, corresponding to an additional feature.

    This method behaves the same as `addVariantsFromConfiguration(Configuration, Action)` but takes a provider of consumable configuration.

    Parameters:
      `outgoingConfiguration` - the provider of the configuration corresponding to the variant to use as source of dependencies and artifacts
      `action` - action executed to configure the variant prior to publishing
    Since:
      9.2.0

  - ### withVariantsFromConfiguration

    void withVariantsFromConfiguration(Configuration outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)
    Further configure previously declared variants.

    The action can be used to determine if the variant should be published or not, and to configure various options specific to the publishing format. Note that if multiple actions are added, they are executed in the order they were added.

    Parameters:
      `outgoingConfiguration` - the configuration corresponding to the variant to configure with a given action
      `action` - an additional action to be executed to configure the variant prior to publishing

  - ### withVariantsFromConfiguration

    @Incubating void withVariantsFromConfiguration(Provider<ConsumableConfiguration> outgoingConfiguration, Action<? super ConfigurationVariantDetails> action)
    Further configure previously declared variants.

    This method behaves the same as `withVariantsFromConfiguration(Configuration, Action)` but takes a provider of consumable configuration.

    Parameters:
      `outgoingConfiguration` - the provider of the configuration corresponding to the variant to configure with a given action
      `action` - an additional action to be executed to configure the variant prior to publishing
    Since:
      9.2.0