Interface BuildFeature


  • @Incubating
    public interface BuildFeature
    Status of a feature in a build that affects Gradle behavior, and may impose additional requirements on plugins or build scripts.

    It is possible to check if the feature is active in the current build. The requested property shows whether the user opted in or opted out from the feature.

    Since:
    8.5
    See Also:
    BuildFeatures
    • Method Detail

      • getRequested

        Provider<java.lang.Boolean> getRequested()
        Whether the feature was requested for the build.

        The provider can be undefined if the user did not explicitly opt in or opt out from a feature. Use Provider.getOrNull() to safely retrieve a nullable value or check Provider.isPresent().

        This method is primarily useful for gathering feature usage statistics, as it corresponds to the user intention.

        Note that the requested state does not always imply that the feature is active in the build. In case an effective status is needed, use getActive().

        Since:
        8.5
      • getActive

        Provider<java.lang.Boolean> getActive()
        Whether the feature is active in the build.

        The provider is always defined and its value denotes the effective status of a feature in a build.

        This method is primarily useful for conditional logic in plugins or build scripts. For instance, optional features of a plugin could be disabled if they are incompatible with a given build feature.

        Note that a feature may be not active even it was requested. This can be caused by other build features or build options requested for the build.

        Since:
        8.5