Component Metadata Handler
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:
- As an action directly when they are applied in the components section
- 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
Adds a class based rule that may modify the metadata of any resolved software component.
Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.artifacts.dsl.ComponentMetadataHandler.all.
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.
Adds a class based rule that may modify the metadata of any resolved software component belonging to the specified module.
Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.artifacts.dsl.ComponentMetadataHandler.withModule.