ComponentMetadataHandler

Allows the build to provide rules that modify the metadata of depended-on software components. Component metadata rules are applied in the components section of the dependencies block DependencyHandler of a build script. The rules can be defined in two different ways:

  1. As an action directly when they are applied in the components section
  2. As an isolated class implementing the ComponentMetadataRule interface

Example shows a basic way of removing certain transitive dependencies from one of our dependencies.

plugins {
    id 'java'
}

repositories {
    mavenCentral()
}

dependencies {
    components {
        withModule("jaxen:jaxen") {
            allVariants {
                withDependencies {
                    removeAll { it.group in ["dom4j", "jdom", "xerces", "maven-plugins", "xml-apis", "xom"] }
                }
            }

        }
    }
    implementation("jaxen:jaxen:1.1.3")
}

Since

1.8

Functions

Link copied to clipboard
abstract fun all(@DelegatesTo(value = ComponentMetadataDetails::class) rule: Closure<out Any>): ComponentMetadataHandler
Adds a rule closure that may modify the metadata of any resolved software component.
abstract fun all(rule: Class<out ComponentMetadataRule>, configureAction: Action<in ActionConfiguration>): ComponentMetadataHandler
Adds a class based rule that may modify the metadata of any resolved software component.
abstract fun all(ruleSource: Any): ComponentMetadataHandler
Adds a rule that may modify the metadata of any resolved software component.
Adds a rule action that may modify the metadata of any resolved software component.
Link copied to clipboard

Adds a class based rule that may modify the metadata of any resolved software component.

inline fun ComponentMetadataHandler.all(rule: KClass<out ComponentMetadataRule>, configureAction: Action<in ActionConfiguration>): ComponentMetadataHandler

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.artifacts.dsl.ComponentMetadataHandler.all.

inline fun <T : ComponentMetadataRule> ComponentMetadataHandler.all(configureAction: Action<in ActionConfiguration>): ComponentMetadataHandler

Adds a class based rule that may modify the metadata of any resolved software component. The rule itself is configured by the provided configure action.

Link copied to clipboard
abstract fun withModule(id: Any, @DelegatesTo(value = ComponentMetadataDetails::class) rule: Closure<out Any>): ComponentMetadataHandler
abstract fun withModule(id: Any, ruleSource: Any): ComponentMetadataHandler
Adds a rule that may modify the metadata of any resolved software component belonging to the specified module.
abstract fun withModule(id: Any, rule: Class<out ComponentMetadataRule>, configureAction: Action<in ActionConfiguration>): ComponentMetadataHandler
Adds a class based rule that may modify the metadata of any resolved software component belonging to the specified module.
Link copied to clipboard
inline fun <T : ComponentMetadataRule> ComponentMetadataHandler.withModule(id: Any, configureAction: Action<in ActionConfiguration>): ComponentMetadataHandler

Adds a class based rule that may modify the metadata of any resolved software component belonging to the specified module.

inline fun ComponentMetadataHandler.withModule(id: Any, rule: KClass<out ComponentMetadataRule>, configureAction: Action<in ActionConfiguration>): ComponentMetadataHandler

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.artifacts.dsl.ComponentMetadataHandler.withModule.