Interface FeatureSpec


public interface FeatureSpec
Handler for configuring features, which may contribute additional configurations, publications, dependencies, ...
Since:
5.3
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    capability(String group, String name, String version)
    Declares a capability of this feature.
    void
    By default, features are published on external repositories.
    void
    Declares the source set which this feature is built from.
    void
    Automatically package Javadoc and register the produced JAR as a variant.
    void
    Automatically package sources from the linked SourceSet and register the produced JAR as a variant.
  • Method Details

    • usingSourceSet

      void usingSourceSet(SourceSet sourceSet)
      Declares the source set which this feature is built from.
      Parameters:
      sourceSet - the source set
    • capability

      void capability(String group, String name, String version)
      Declares a capability of this feature.

      Calling this method multiple times will declare additional capabilities. Note that calling this method will drop the default capability that is added by JavaPluginExtension.registerFeature(String, org.gradle.api.Action). If you want to keep the default capability and add a new one you need to restore the default capability:

       registerFeature("myFeature") {
           capability("${project.group}", "${project.name}-my-feature", "${project.version}")
           capability("com.example", "some-other-capability", "2.0")
       }
       
      Parameters:
      group - the group of the capability
      name - the name of the capability
      version - the version of the capability
    • withJavadocJar

      void withJavadocJar()
      Automatically package Javadoc and register the produced JAR as a variant. See also JavaPluginExtension.withJavadocJar().
      Since:
      6.0
    • withSourcesJar

      void withSourcesJar()
      Automatically package sources from the linked SourceSet and register the produced JAR as a variant. See also JavaPluginExtension.withSourcesJar().
      Since:
      6.0
    • disablePublication

      void disablePublication()
      By default, features are published on external repositories. Calling this method allows disabling publishing.
      Since:
      6.7