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));
}
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());
}
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);
}
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);
}
}
}
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);
}
}
Aggregations