Search in sources :

Example 1 with ArtifactSelectionDetailsInternal

use of org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.ArtifactSelectionDetailsInternal 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;
}
Also used : ArtifactSelectionDetailsInternal(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.ArtifactSelectionDetailsInternal) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) DependencySubstitutionApplicator(org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator) DependencySubstitutionInternal(org.gradle.api.internal.artifacts.DependencySubstitutionInternal)

Aggregations

DependencySubstitutionInternal (org.gradle.api.internal.artifacts.DependencySubstitutionInternal)1 ArtifactSelectionDetailsInternal (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.ArtifactSelectionDetailsInternal)1 DependencySubstitutionApplicator (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator)1 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)1