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
@Incubating @NonExtensible public abstract class DependencyModifier extends java.lang.Object
ADependencyModifier
defines how to modify a dependency inside a customdependencies
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)
. Otherabstract
methods 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 DSL
orextension functions for Kotlin DSL
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DependencyModifier()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract DependencyFactory
getDependencyFactory()
A dependency factory is used to convert supported dependency notations intoDependency
instances.<D extends ModuleDependency>
Dmodify(D dependency)
Takes a givenModuleDependency
and modifies the dependency to select the variant of the given module.ExternalModuleDependency
modify(java.lang.CharSequence dependencyNotation)
Create anExternalModuleDependency
from the given notation and modifies it to select the variant of the given module as described inmodify(ModuleDependency)
.<D extends ModuleDependency>
Provider<D>modify(Provider<D> providerToDependency)
Takes a givenProvider
to aExternalModuleDependency
and modifies the dependency to select the variant of the given module as described inmodify(ModuleDependency)
.Provider<? extends MinimalExternalModuleDependency>
modify(ProviderConvertible<? extends MinimalExternalModuleDependency> providerConvertibleToDependency)
Takes a givenProvider
to aMinimalExternalModuleDependency
and modifies the dependency to select the variant of the given module as described inmodify(ModuleDependency)
.protected abstract void
modifyImplementation(ModuleDependency dependency)
Modify the given dependency.
-
-
-
Method Detail
-
getDependencyFactory
@Inject protected abstract DependencyFactory getDependencyFactory()
A dependency factory is used to convert supported dependency notations intoDependency
instances.- Returns:
- a dependency factory
- See Also:
DependencyFactory
- Implementation Requirements:
- Do not implement this method. Gradle generates the implementation automatically.
-
modify
public final ExternalModuleDependency modify(java.lang.CharSequence dependencyNotation)
Create anExternalModuleDependency
from 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:
DependencyFactory.create(CharSequence)
-
modify
public final Provider<? extends MinimalExternalModuleDependency> modify(ProviderConvertible<? extends MinimalExternalModuleDependency> providerConvertibleToDependency)
Takes a givenProvider
to aMinimalExternalModuleDependency
and 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
public final <D extends ModuleDependency> Provider<D> modify(Provider<D> providerToDependency)
Takes a givenProvider
to aExternalModuleDependency
and 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
public final <D extends ModuleDependency> D modify(D dependency)
Takes a givenModuleDependency
and 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
protected abstract void modifyImplementation(ModuleDependency dependency)
Modify the given dependency.- Parameters:
dependency
- the dependency to modify- Since:
- 8.4
- Implementation Requirements:
- This method must be implemented.
-
-