Search in sources :

Example 1 with ProjectComponentSelector

use of org.gradle.api.artifacts.component.ProjectComponentSelector 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 ProjectComponentSelector

use of org.gradle.api.artifacts.component.ProjectComponentSelector in project gradle by gradle.

the class DefaultDependencyMetadata method withTarget.

@Override
public DependencyMetadata withTarget(ComponentSelector target) {
    if (target instanceof ModuleComponentSelector) {
        ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target;
        ModuleVersionSelector requestedVersion = DefaultModuleVersionSelector.newSelector(moduleTarget.getGroup(), moduleTarget.getModule(), moduleTarget.getVersion());
        if (requestedVersion.equals(requested)) {
            return this;
        }
        return withRequested(requestedVersion);
    } else if (target instanceof ProjectComponentSelector) {
        ProjectComponentSelector projectTarget = (ProjectComponentSelector) target;
        return new DefaultProjectDependencyMetadata(projectTarget, this);
    } else {
        throw new IllegalArgumentException("Unexpected selector provided: " + target);
    }
}
Also used : DefaultProjectDependencyMetadata(org.gradle.internal.component.local.model.DefaultProjectDependencyMetadata) DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector)

Example 3 with ProjectComponentSelector

use of org.gradle.api.artifacts.component.ProjectComponentSelector in project gradle by gradle.

the class LocalComponentDependencyMetadata method withTarget.

@Override
public LocalOriginDependencyMetadata withTarget(ComponentSelector target) {
    if (target instanceof ModuleComponentSelector) {
        ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target;
        ModuleVersionSelector requestedVersion = DefaultModuleVersionSelector.newSelector(moduleTarget.getGroup(), moduleTarget.getModule(), moduleTarget.getVersion());
        if (selector.equals(target) && requested.equals(requestedVersion)) {
            return this;
        }
        return copyWithTarget(moduleTarget, requestedVersion);
    } else if (target instanceof ProjectComponentSelector) {
        if (target.equals(selector)) {
            return this;
        }
        return copyWithTarget(target, requested);
    } else {
        throw new AssertionError("Invalid component selector type for substitution: " + target);
    }
}
Also used : DefaultModuleVersionSelector(org.gradle.api.internal.artifacts.DefaultModuleVersionSelector) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector)

Example 4 with ProjectComponentSelector

use of org.gradle.api.artifacts.component.ProjectComponentSelector 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 5 with ProjectComponentSelector

use of org.gradle.api.artifacts.component.ProjectComponentSelector in project gradle by gradle.

the class ProjectDependencyResolver method resolve.

@Override
public void resolve(DependencyMetadata dependency, ResolvedVersionConstraint versionConstraint, 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)

Aggregations

ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)14 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)9 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)7 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)6 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)5 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)4 LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)4 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)3 DefaultProjectDependencyMetadata (org.gradle.internal.component.local.model.DefaultProjectDependencyMetadata)3 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)2 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)2 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)2 Action (org.gradle.api.Action)1 ArtifactSelectionDetails (org.gradle.api.artifacts.ArtifactSelectionDetails)1 DependencySubstitution (org.gradle.api.artifacts.DependencySubstitution)1 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)1 LibraryComponentSelector (org.gradle.api.artifacts.component.LibraryComponentSelector)1 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)1 ResolutionResult (org.gradle.api.artifacts.result.ResolutionResult)1