Interface FeatureSpec


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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void capability​(java.lang.String group, java.lang.String name, java.lang.String version)
      Declares a capability of this feature.
      void disablePublication()
      By default, features are published on external repositories.
      void usingSourceSet​(SourceSet sourceSet)
      Declares the source set which this feature is built from.
      void withJavadocJar()
      Automatically package Javadoc and register the produced JAR as a variant.
      void withSourcesJar()
      Automatically package sources from the linked SourceSet and register the produced JAR as a variant.
    • Method Detail

      • usingSourceSet

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

        void capability​(java.lang.String group,
                        java.lang.String name,
                        java.lang.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
      • disablePublication

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