use of org.gradle.api.artifacts.ArtifactSelectionDetails in project gradle by gradle.
the class DefaultDependencySubstitutions method substitute.
@Override
public Substitution substitute(final ComponentSelector substituted) {
return new Substitution() {
Action<? super ArtifactSelectionDetails> artifactAction = Actions.doNothing();
ComponentSelectionDescriptorInternal substitutionReason = (ComponentSelectionDescriptorInternal) reason;
@Override
public Substitution because(String description) {
substitutionReason = substitutionReason.withDescription(Describables.of(description));
return this;
}
@Override
public Substitution withClassifier(String classifier) {
artifactAction = Actions.composite(artifactAction, new SetClassifier(classifier));
return this;
}
@Override
public Substitution withoutClassifier() {
artifactAction = Actions.composite(artifactAction, NoClassifier.INSTANCE);
return this;
}
@Override
public Substitution withoutArtifactSelectors() {
artifactAction = Actions.composite(artifactAction, NoArtifactSelector.INSTANCE);
return this;
}
@Override
public Substitution using(ComponentSelector notation) {
DefaultDependencySubstitution.validateTarget(notation);
boolean projectInvolved = false;
if (substituted instanceof ProjectComponentSelector || notation instanceof ProjectComponentSelector) {
// A project is involved, need to be aware of it
projectInvolved = true;
}
if (substituted instanceof UnversionedModuleComponentSelector) {
final ModuleIdentifier moduleId = ((UnversionedModuleComponentSelector) substituted).getModuleIdentifier();
if (notation instanceof ModuleComponentSelector) {
if (((ModuleComponentSelector) notation).getModuleIdentifier().equals(moduleId)) {
// This substitution is effectively a force
substitutionReason = substitutionReason.markAsEquivalentToForce();
}
}
addSubstitution(new ModuleMatchDependencySubstitutionAction(substitutionReason, moduleId, notation, () -> artifactAction), projectInvolved);
} else {
addSubstitution(new ExactMatchDependencySubstitutionAction(substitutionReason, substituted, notation, () -> artifactAction), projectInvolved);
}
return this;
}
@Override
@Deprecated
public void with(ComponentSelector substitute) {
// Do not nag for 7.1 as this introduces a performance regression with Android plugin
// Revisit when upgrading Android plugin
/*DeprecationLogger.deprecateMethod(Substitution.class, "with(ComponentSelector)")
.replaceWith("using(ComponentSelector)")
.willBeRemovedInGradle8()
.withUpgradeGuideSection(7, "dependency_substitutions_with")
.nagUser();*/
using(substitute);
}
};
}
Aggregations