Package org.gradle.api.artifacts.dsl
Class DependencyModifier
java.lang.Object
org.gradle.api.artifacts.dsl.DependencyModifier
- Direct Known Subclasses:
PlatformDependencyModifiers.EnforcedPlatformDependencyModifier,PlatformDependencyModifiers.PlatformDependencyModifier,TestFixturesDependencyModifiers.TestFixturesDependencyModifier
A
DependencyModifier defines how to modify a dependency inside a custom dependencies block to select a different variant.- Since:
- 8.0
- API Note:
- Gradle has specific extensions to make explicit calls to
modify(...)unnecessary from the DSL.- For Groovy DSL, we create
call(...)equivalents for all themodify(...)methods. - For Kotlin DSL, we create
invoke(...)equivalents for all themodify(...)methods.
- For Groovy DSL, we create
- Implementation Requirements:
- The only method that should be implemented is
modifyImplementation(ModuleDependency). Otherabstractmethods are used to inject necessary services and should not be implemented. - Implementation Note:
- All implementations of
modify(...)delegate tomodifyImplementation(ModuleDependency).Changes to this interface may require changes to the
extension module for Groovy DSLorextension functions for Kotlin DSL.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DependencyFactoryA dependency factory is used to convert supported dependency notations intoDependencyinstances.final <D extends ModuleDependency>
Dmodify(D dependency) Takes a givenModuleDependencyand modifies the dependency to select the variant of the given module.final ExternalModuleDependencymodify(CharSequence dependencyNotation) Create anExternalModuleDependencyfrom the given notation and modifies it to select the variant of the given module as described inmodify(ModuleDependency).final <D extends ModuleDependency>
Provider<D>Takes a givenProviderto aExternalModuleDependencyand modifies the dependency to select the variant of the given module as described inmodify(ModuleDependency).final Provider<? extends MinimalExternalModuleDependency>modify(ProviderConvertible<? extends MinimalExternalModuleDependency> providerConvertibleToDependency) Takes a givenProviderto aMinimalExternalModuleDependencyand modifies the dependency to select the variant of the given module as described inmodify(ModuleDependency).protected abstract voidmodifyImplementation(ModuleDependency dependency) Modify the given dependency.
-
Constructor Details
-
DependencyModifier
protected DependencyModifier()Creates a new instance.- Since:
- 8.4
-
-
Method Details
-
getDependencyFactory
A dependency factory is used to convert supported dependency notations intoDependencyinstances.- Returns:
- a dependency factory
- See Also:
- Implementation Requirements:
- Do not implement this method. Gradle generates the implementation automatically.
-
modify
Create anExternalModuleDependencyfrom the given notation and modifies it to select the variant of the given module as described inmodify(ModuleDependency).- Parameters:
dependencyNotation- the dependency notation- Returns:
- the modified dependency
- See Also:
-
modify
@Incubating public final Provider<? extends MinimalExternalModuleDependency> modify(ProviderConvertible<? extends MinimalExternalModuleDependency> providerConvertibleToDependency) Takes a givenProviderto aMinimalExternalModuleDependencyand modifies the dependency to select the variant of the given module as described inmodify(ModuleDependency).- Parameters:
providerConvertibleToDependency- the provider- Returns:
- a provider to the modified dependency
-
modify
Takes a givenProviderto aExternalModuleDependencyand modifies the dependency to select the variant of the given module as described inmodify(ModuleDependency).- Parameters:
providerToDependency- the provider- Returns:
- a provider to the modified dependency
-
modify
Takes a givenModuleDependencyand modifies the dependency to select the variant of the given module. Dependency resolution may fail if the given module does not have a compatible variant.The dependency will be copied, so the original dependency will not be modified.
- Type Parameters:
D- the type of theModuleDependency- Parameters:
dependency- the dependency to modify- Returns:
- the modified dependency
-
modifyImplementation
Modify the given dependency.- Parameters:
dependency- the dependency to modify- Since:
- 8.4
- Implementation Requirements:
- This method must be implemented.
-