Search in sources :

Example 1 with ModuleVersionResolveException

use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.

the class DefaultIncludedBuildExecuter method checkNoCycles.

private void checkNoCycles(BuildRequest buildRequest, BuildIdentifier target, List<BuildIdentifier> candidateCycle) {
    candidateCycle.add(target);
    for (BuildRequest executingBuild : executingBuilds) {
        if (executingBuild.requestingBuild.equals(target)) {
            BuildIdentifier nextTarget = executingBuild.targetBuild;
            if (nextTarget.equals(buildRequest.requestingBuild)) {
                candidateCycle.add(nextTarget);
                ProjectComponentSelector selector = DefaultProjectComponentSelector.newSelector(buildRequest.targetBuild, ":");
                throw new ModuleVersionResolveException(selector, "Included build dependency cycle: " + reportCycle(candidateCycle));
            }
            checkNoCycles(buildRequest, nextTarget, candidateCycle);
        }
    }
    candidateCycle.remove(target);
}
Also used : ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Example 2 with ModuleVersionResolveException

use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.

the class ProjectDependencyResolver method resolve.

@Override
public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) {
    if (dependency.getSelector() instanceof ProjectComponentSelector) {
        ProjectComponentSelector selector = (ProjectComponentSelector) dependency.getSelector();
        ProjectComponentIdentifier project = componentIdentifierFactory.createProjectComponentIdentifier(selector);
        LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(project);
        if (componentMetaData == null) {
            result.failed(new ModuleVersionResolveException(selector, project + " not found."));
        } else {
            result.resolved(componentMetaData);
        }
    }
}
Also used : ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) LocalComponentMetadata(org.gradle.internal.component.local.model.LocalComponentMetadata) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 3 with ModuleVersionResolveException

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

Example 4 with ModuleVersionResolveException

use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.

the class DynamicVersionResolver method resolve.

public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) {
    ModuleVersionSelector requested = dependency.getRequested();
    LOGGER.debug("Attempting to resolve version for {} using repositories {}", requested, repositoryNames);
    List<Throwable> errors = new ArrayList<Throwable>();
    List<RepositoryResolveState> resolveStates = new ArrayList<RepositoryResolveState>();
    for (ModuleComponentRepository repository : repositories) {
        resolveStates.add(new RepositoryResolveState(dependency, repository));
    }
    final RepositoryChainModuleResolution latestResolved = findLatestModule(resolveStates, errors);
    if (latestResolved != null) {
        LOGGER.debug("Using {} from {}", latestResolved.module.getId(), latestResolved.repository);
        for (Throwable error : errors) {
            LOGGER.debug("Discarding resolve failure.", error);
        }
        result.resolved(metaDataFactory.transform(latestResolved));
        return;
    }
    if (!errors.isEmpty()) {
        result.failed(new ModuleVersionResolveException(requested, errors));
    } else {
        notFound(result, requested, resolveStates);
    }
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ArrayList(java.util.ArrayList) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Example 5 with ModuleVersionResolveException

use of org.gradle.internal.resolve.ModuleVersionResolveException in project gradle by gradle.

the class DynamicVersionResolver method resolve.

public void resolve(ModuleDependencyMetadata dependency, VersionSelector versionSelector, VersionSelector rejectedVersionSelector, BuildableComponentIdResolveResult result) {
    ModuleComponentSelector requested = dependency.getSelector();
    LOGGER.debug("Attempting to resolve version for {} using repositories {}", requested, repositoryNames);
    List<Throwable> errors = new ArrayList<Throwable>();
    List<RepositoryResolveState> resolveStates = Lists.newArrayListWithCapacity(repositories.size());
    for (ModuleComponentRepository repository : repositories) {
        resolveStates.add(new RepositoryResolveState(versionedComponentChooser, dependency, repository, versionSelector, rejectedVersionSelector));
    }
    final RepositoryChainModuleResolution latestResolved = findLatestModule(resolveStates, errors);
    if (latestResolved != null) {
        LOGGER.debug("Using {} from {}", latestResolved.module.getModuleVersionId(), latestResolved.repository);
        for (Throwable error : errors) {
            LOGGER.debug("Discarding resolve failure.", error);
        }
        result.resolved(metaDataFactory.transform(latestResolved));
        return;
    }
    if (!errors.isEmpty()) {
        result.failed(new ModuleVersionResolveException(requested, errors));
    } else {
        notFound(result, requested, resolveStates);
    }
}
Also used : ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ArrayList(java.util.ArrayList) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Aggregations

ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)28 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)7 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)7 LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)7 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)5 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)5 ArrayList (java.util.ArrayList)4 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)4 DependencySubstitutionInternal (org.gradle.api.internal.artifacts.DependencySubstitutionInternal)3 ComponentResolveMetadata (org.gradle.internal.component.model.ComponentResolveMetadata)3 File (java.io.File)2 ComponentMetadataDetails (org.gradle.api.artifacts.ComponentMetadataDetails)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)2 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)2 DependencySubstitutionApplicator (org.gradle.api.internal.artifacts.ivyservice.dependencysubstitution.DependencySubstitutionApplicator)2 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)2 Pair (org.gradle.internal.Pair)2 ModuleComponentResolveMetadata (org.gradle.internal.component.external.model.ModuleComponentResolveMetadata)2 MutableModuleComponentResolveMetadata (org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata)2