Search in sources :

Example 6 with ProjectComponentIdentifier

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

the class EclipsePlugin method registerEclipseArtifacts.

private static void registerEclipseArtifacts(Project project) {
    ProjectLocalComponentProvider projectComponentProvider = ((ProjectInternal) project).getServices().get(ProjectLocalComponentProvider.class);
    ProjectComponentIdentifier projectId = newProjectId(project);
    String projectName = project.getExtensions().getByType(EclipseModel.class).getProject().getName();
    projectComponentProvider.registerAdditionalArtifact(projectId, createArtifact("project", projectId, projectName, project));
    projectComponentProvider.registerAdditionalArtifact(projectId, createArtifact("classpath", projectId, projectName, project));
}
Also used : ProjectLocalComponentProvider(org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectLocalComponentProvider) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 7 with ProjectComponentIdentifier

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

the class DefaultResolvedArtifactsBuilder method visitArtifacts.

@Override
public void visitArtifacts(DependencyGraphNode from, DependencyGraphNode to, ArtifactSet artifacts) {
    if (sortOrder != ResolutionStrategy.SortOrder.DEFAULT) {
        sortedNodeIds.get(to.getNodeId()).add(artifacts);
    } else {
        artifactSets.put(artifacts.getId(), artifacts);
    }
    // Don't collect build dependencies if not required
    if (!buildProjectDependencies) {
        return;
    }
    if (buildableArtifactSets.contains(artifacts.getId())) {
        return;
    }
    // Collect the build dependencies in 2 steps: collect the artifact sets while traversing and at the end of traversal unpack the build dependencies for each
    // We need to discard the artifact sets to avoid keeping strong references
    ConfigurationMetadata configurationMetadata = to.getMetadata();
    if (!(configurationMetadata instanceof LocalConfigurationMetadata)) {
        return;
    }
    if (from.getOwner().getComponentId() instanceof ProjectComponentIdentifier) {
        // This is here to attempt to leave out build dependencies that would cause a cycle in the task graph for the current build, so that the cross-build cycle detection kicks in. It's not fully correct
        ProjectComponentIdentifier incomingId = (ProjectComponentIdentifier) from.getOwner().getComponentId();
        if (!incomingId.getBuild().isCurrentBuild()) {
            return;
        }
    }
    buildableArtifactSets.add(artifacts.getId());
}
Also used : LocalConfigurationMetadata(org.gradle.internal.component.local.model.LocalConfigurationMetadata) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) ConfigurationMetadata(org.gradle.internal.component.model.ConfigurationMetadata) LocalConfigurationMetadata(org.gradle.internal.component.local.model.LocalConfigurationMetadata)

Example 8 with ProjectComponentIdentifier

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

the class ProjectDependencyForcingResolver method select.

@Override
public <T extends ComponentResolutionState> T select(Collection<? extends T> candidates) {
    // the collection will only be initialized if more than one project candidate is found
    Collection<T> projectCandidates = null;
    T foundProjectCandidate = null;
    // fine one or more project dependencies among conflicting modules
    for (T candidate : candidates) {
        ComponentResolveMetadata metaData = candidate.getMetaData();
        if (metaData != null && metaData.getComponentId() instanceof ProjectComponentIdentifier) {
            if (foundProjectCandidate == null) {
                // found the first project dependency
                foundProjectCandidate = candidate;
            } else {
                // found more than one
                if (projectCandidates == null) {
                    projectCandidates = new ArrayList<T>();
                    projectCandidates.add(foundProjectCandidate);
                }
                projectCandidates.add(candidate);
            }
        }
    }
    // let the delegate resolver select among them
    if (projectCandidates != null) {
        return delegate.select(projectCandidates);
    }
    // if found only one project dependency - return it, otherwise call the next resolver
    return foundProjectCandidate != null ? foundProjectCandidate : delegate.select(candidates);
}
Also used : ComponentResolveMetadata(org.gradle.internal.component.model.ComponentResolveMetadata) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 9 with ProjectComponentIdentifier

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

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

the class ComponentIdentifierSerializer method write.

public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
    if (value == null) {
        throw new IllegalArgumentException("Provided component identifier may not be null");
    }
    Implementation implementation = resolveImplementation(value);
    encoder.writeByte(implementation.getId());
    if (implementation == Implementation.MODULE) {
        ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) value;
        encoder.writeString(moduleComponentIdentifier.getGroup());
        encoder.writeString(moduleComponentIdentifier.getModule());
        encoder.writeString(moduleComponentIdentifier.getVersion());
    } else if (implementation == Implementation.BUILD) {
        ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) value;
        BuildIdentifier build = projectComponentIdentifier.getBuild();
        buildIdentifierSerializer.write(encoder, build);
        encoder.writeString(projectComponentIdentifier.getProjectPath());
    } else if (implementation == Implementation.LIBRARY) {
        LibraryBinaryIdentifier libraryIdentifier = (LibraryBinaryIdentifier) value;
        encoder.writeString(libraryIdentifier.getProjectPath());
        encoder.writeString(libraryIdentifier.getLibraryName());
        encoder.writeString(libraryIdentifier.getVariant());
    } else {
        throw new IllegalStateException("Unsupported implementation type: " + implementation);
    }
}
Also used : ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier) DefaultLibraryBinaryIdentifier(org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)

Aggregations

ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)17 File (java.io.File)4 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)4 ResolvedComponentResult (org.gradle.api.artifacts.result.ResolvedComponentResult)4 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)3 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)3 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)3 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)3 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)3 LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)3 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)3 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 Project (org.gradle.api.Project)2 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)2 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)2 LocalComponentRegistry (org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry)2 ProjectLocalComponentProvider (org.gradle.api.internal.artifacts.ivyservice.projectmodule.ProjectLocalComponentProvider)2 DefaultLocalComponentMetadata (org.gradle.internal.component.local.model.DefaultLocalComponentMetadata)2 DefaultProjectComponentIdentifier (org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)2