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
ADependencyModifierdefines how to modify a dependency inside a customdependenciesblock 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 Modifier Constructor Description protectedDependencyModifier()Creates a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract DependencyFactorygetDependencyFactory()A dependency factory is used to convert supported dependency notations intoDependencyinstances.<D extends ModuleDependency>
Dmodify(D dependency)Takes a givenModuleDependencyand modifies the dependency to select the variant of the given module.ExternalModuleDependencymodify(java.lang.CharSequence dependencyNotation)Create anExternalModuleDependencyfrom 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 givenProviderto aExternalModuleDependencyand 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 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.
-
-
-
Method Detail
-
getDependencyFactory
@Inject protected abstract DependencyFactory getDependencyFactory()
A dependency factory is used to convert supported dependency notations intoDependencyinstances.- 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 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:
DependencyFactory.create(CharSequence)
-
modify
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
public final <D extends ModuleDependency> Provider<D> modify(Provider<D> providerToDependency)
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
public final <D extends ModuleDependency> D modify(D dependency)
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
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.
-
-