package org.implab.gradle.variants.artifacts;

import org.gradle.api.Action;
import org.gradle.api.artifacts.Configuration;
import org.implab.gradle.common.core.lang.Closures;
import org.implab.gradle.variants.core.Variant;

import groovy.lang.Closure;

/**
 * Materialized root outgoing configuration of a variant.
 *
 * <p>This is a variant-level publication hook. Slot-specific publication state is exposed separately via
 * {@link OutgoingConfigurationSlotSpec}.
 */
public interface OutgoingConfigurationSpec {
    /**
     * Returns the variant whose outgoing configuration is represented here.
     *
     * @return variant identity
     */
    Variant getVariant();

    /**
     * Returns the root consumable outgoing configuration of the variant.
     *
     * @return outgoing configuration
     */
    Configuration getConfiguration();

    /**
     * Applies a configuration action to the root outgoing configuration.
     *
     * @param action configuration action
     */
    default void configuration(Action<? super Configuration> action) {
        action.execute(getConfiguration());
    }

    default void configuration(Closure<?> closure) {
        configuration(Closures.action(closure));
    }
}
