use of org.gradle.api.internal.artifacts.DependencySubstitutionInternal in project gradle by gradle.
the class DependencySubstitutionResolver method resolve.
public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) {
ComponentSelector selector = dependency.getSelector();
DependencySubstitutionInternal details = new DefaultDependencySubstitution(selector, dependency.getRequested());
try {
rule.execute(details);
} catch (Throwable e) {
result.failed(new ModuleVersionResolveException(selector, e));
return;
}
if (details.isUpdated()) {
resolver.resolve(dependency.withTarget(details.getTarget()), result);
result.setSelectionReason(details.getSelectionReason());
return;
}
resolver.resolve(dependency, result);
}
use of org.gradle.api.internal.artifacts.DependencySubstitutionInternal in project gradle by gradle.
the class NodeState method maybeSubstitute.
/**
* Execute any dependency substitution rules that apply to this dependency.
*
* This may be better done as a decorator on ConfigurationMetadata.getDependencies()
*/
static DependencyState maybeSubstitute(DependencyState dependencyState, DependencySubstitutionApplicator dependencySubstitutionApplicator) {
DependencySubstitutionApplicator.SubstitutionResult substitutionResult = dependencySubstitutionApplicator.apply(dependencyState.getDependency());
if (substitutionResult.hasFailure()) {
dependencyState.failure = new ModuleVersionResolveException(dependencyState.getRequested(), substitutionResult.getFailure());
return dependencyState;
}
DependencySubstitutionInternal details = substitutionResult.getResult();
if (details != null && details.isUpdated()) {
ArtifactSelectionDetailsInternal artifactSelectionDetails = details.getArtifactSelectionDetails();
if (artifactSelectionDetails.isUpdated()) {
return dependencyState.withTargetAndArtifacts(details.getTarget(), artifactSelectionDetails.getTargetSelectors(), details.getRuleDescriptors());
}
return dependencyState.withTarget(details.getTarget(), details.getRuleDescriptors());
}
return dependencyState;
}
use of org.gradle.api.internal.artifacts.DependencySubstitutionInternal in project gradle by gradle.
the class NodeState method maybeSubstitute.
/**
* Execute any dependency substitution rules that apply to this dependency.
*
* This may be better done as a decorator on ConfigurationMetadata.getDependencies()
*/
private DependencyState maybeSubstitute(DependencyState dependencyState) {
DependencySubstitutionApplicator.SubstitutionResult substitutionResult = resolveState.getDependencySubstitutionApplicator().apply(dependencyState.getDependency());
if (substitutionResult.hasFailure()) {
dependencyState.failure = new ModuleVersionResolveException(dependencyState.getRequested(), substitutionResult.getFailure());
return dependencyState;
}
DependencySubstitutionInternal details = substitutionResult.getResult();
if (details != null && details.isUpdated()) {
return dependencyState.withTarget(details.getTarget(), details.getSelectionDescription());
}
return dependencyState;
}
use of org.gradle.api.internal.artifacts.DependencySubstitutionInternal in project gradle by gradle.
the class CompositeBuildDependencySubstitutions method execute.
@Override
public void execute(DependencySubstitution sub) {
DependencySubstitutionInternal dependencySubstitution = (DependencySubstitutionInternal) sub;
// Use the result of previous rules as the input for dependency substitution
ComponentSelector requested = dependencySubstitution.getTarget();
if (requested instanceof ModuleComponentSelector) {
ModuleComponentSelector selector = (ModuleComponentSelector) requested;
ProjectComponentIdentifier replacement = getReplacementFor(selector);
if (replacement != null) {
ProjectComponentSelector targetProject = DefaultProjectComponentSelector.newSelector(replacement, ((AttributeContainerInternal) requested.getAttributes()).asImmutable(), requested.getRequestedCapabilities());
dependencySubstitution.useTarget(targetProject, ComponentSelectionReasons.COMPOSITE_BUILD);
}
}
}
Aggregations