use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class CompositeBuildDependencySubstitutions method getReplacementFor.
private ProjectComponentIdentifier getReplacementFor(ModuleComponentSelector selector) {
ModuleIdentifier candidateId = moduleIdentifierFactory.module(selector.getGroup(), selector.getModule());
Collection<ProjectComponentIdentifier> providingProjects = replacementMap.get(candidateId);
if (providingProjects.isEmpty()) {
LOGGER.debug("Found no composite build substitute for module '" + candidateId + "'.");
return null;
}
if (providingProjects.size() == 1) {
ProjectComponentIdentifier match = providingProjects.iterator().next();
LOGGER.info("Found project '" + match + "' as substitute for module '" + candidateId + "'.");
return match;
}
SortedSet<String> sortedProjects = Sets.newTreeSet(CollectionUtils.collect(providingProjects, new Transformer<String, ProjectComponentIdentifier>() {
@Override
public String transform(ProjectComponentIdentifier projectComponentIdentifier) {
return projectComponentIdentifier.getDisplayName();
}
}));
String failureMessage = String.format("Module version '%s' is not unique in composite: can be provided by %s.", selector.getDisplayName(), sortedProjects);
throw new ModuleVersionResolveException(selector, failureMessage);
}
use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class DefaultIncludedBuild method registerProject.
private void registerProject(Set<Pair<ModuleVersionIdentifier, ProjectComponentIdentifier>> availableModules, ProjectInternal project) {
LocalComponentRegistry localComponentRegistry = project.getServices().get(LocalComponentRegistry.class);
ProjectComponentIdentifier originalIdentifier = newProjectId(project);
DefaultLocalComponentMetadata originalComponent = (DefaultLocalComponentMetadata) localComponentRegistry.getComponent(originalIdentifier);
ProjectComponentIdentifier componentIdentifier = idForProjectInThisBuild(project.getPath());
ModuleVersionIdentifier moduleId = originalComponent.getModuleVersionId();
LOGGER.info("Registering " + project + " in composite build. Will substitute for module '" + moduleId.getModule() + "'.");
availableModules.add(Pair.of(moduleId, componentIdentifier));
}
use of org.gradle.api.artifacts.component.ProjectComponentIdentifier in project gradle by gradle.
the class IncludedBuildDependencyMetadataBuilder method build.
public Map<ProjectComponentIdentifier, RegisteredProject> build(IncludedBuildInternal build) {
Map<ProjectComponentIdentifier, RegisteredProject> registeredProjects = Maps.newHashMap();
Gradle gradle = build.getConfiguredBuild();
for (Project project : gradle.getRootProject().getAllprojects()) {
registerProject(registeredProjects, build, (ProjectInternal) project);
}
return registeredProjects;
}
Aggregations