use of org.gradle.api.artifacts.ModuleVersionIdentifier in project atlas by alibaba.
the class ResolvedDependencyContainer method reslovedDependencies.
/**
* 进行依赖仲裁
*/
public synchronized DependencyTree reslovedDependencies() {
if (inited) {
return dependencyTree;
}
if (!conflictDependencies.isEmpty()) {
for (String str : conflictDependencies) {
logger.error(str);
}
if (null == forceMap) {
throw new GradleException("conflict dependencis");
} else {
AtlasBuildContext.conflictDependencies = conflictDependencies;
}
}
// 仲裁后的依赖关系.结构为父类-子类
Multimap<ModuleVersionIdentifier, ResolvedDependencyInfo> resolvedDependenciesMap = LinkedHashMultimap.create();
Map<ModuleVersionIdentifier, ResolvedDependencyInfo> directDependencies = new HashMap<ModuleVersionIdentifier, ResolvedDependencyInfo>();
for (String key : dependenciesMap.keySet()) {
Collection<ResolvedDependencyInfo> dependencyLevels = dependenciesMap.get(key);
if (dependencyLevels.size() > 0) {
List<ResolvedDependencyInfo> resolvedDependencyInfos = Lists.newArrayList();
resolvedDependencyInfos.addAll(dependencyLevels);
Collections.sort(resolvedDependencyInfos);
ResolvedDependencyInfo resolvedDependencyInfo = resolvedDependencyInfos.get(0);
ResolvedDependencyInfo parent = resolvedDependencyInfo.getParent();
//对于放入resolvedDependenciesMap中的信息不需要加入children
resolvedDependencyInfo.setChildren(Lists.<ResolvedDependencyInfo>newArrayList());
if (null != parent) {
//如果存在的父依赖,就把当前依赖加入到父依赖的子依赖中
resolvedDependenciesMap.put(parent.getModuleVersionIdentifier(), resolvedDependencyInfo);
} else {
//如果没有父依赖,就是一级依赖
directDependencies.put(resolvedDependencyInfo.getModuleVersionIdentifier(), resolvedDependencyInfo);
}
}
}
// 开始构建依赖树
dependencyTree.clear();
for (ModuleVersionIdentifier key : directDependencies.keySet()) {
ResolvedDependencyInfo resolvedDependencyInfo = directDependencies.get(key);
//清空children
resolvedDependencyInfo.setChildren(Lists.<ResolvedDependencyInfo>newArrayList());
addResolvedDependencyInfo(resolvedDependencyInfo, resolvedDependenciesMap);
dependencyTree.addDependency(resolvedDependencyInfo);
}
inited = true;
return dependencyTree;
}
use of org.gradle.api.artifacts.ModuleVersionIdentifier in project gradle by gradle.
the class RejectedModuleMessageBuilder method pathTo.
private static Collection<String> pathTo(EdgeState edge) {
List<List<EdgeState>> acc = Lists.newArrayListWithExpectedSize(1);
pathTo(edge, Lists.<EdgeState>newArrayList(), acc, Sets.<NodeState>newHashSet());
List<String> result = Lists.newArrayListWithCapacity(acc.size());
for (List<EdgeState> path : acc) {
EdgeState target = Iterators.getLast(path.iterator());
StringBuilder sb = new StringBuilder();
if (target.getSelector().getDependencyMetadata().isPending()) {
sb.append("Constraint path ");
} else {
sb.append("Dependency path ");
}
for (EdgeState e : path) {
ModuleVersionIdentifier id = e.getFrom().getResolvedConfigurationId().getId();
sb.append('\'').append(id).append('\'');
sb.append(" --> ");
}
ModuleIdentifier moduleId = edge.getTargetComponent().getModule().getId();
sb.append('\'').append(moduleId.getGroup()).append(':').append(moduleId.getName()).append('\'');
result.add(sb.toString());
}
return result;
}
use of org.gradle.api.artifacts.ModuleVersionIdentifier in project gradle by gradle.
the class DefaultRootComponentMetadataBuilder method toRootComponentMetaData.
@Override
public ComponentResolveMetadata toRootComponentMetaData() {
Module module = metaDataProvider.getModule();
ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
DefaultLocalComponentMetadata metaData = holder.tryCached(componentIdentifier);
if (metaData != null) {
return metaData;
}
ModuleVersionIdentifier moduleVersionIdentifier = moduleIdentifierFactory.moduleWithVersion(module.getGroup(), module.getName(), module.getVersion());
ProjectInternal project = projectFinder.findProject(module.getProjectPath());
AttributesSchemaInternal schema = project == null ? null : (AttributesSchemaInternal) project.getDependencies().getAttributesSchema();
metaData = new DefaultLocalComponentMetadata(moduleVersionIdentifier, componentIdentifier, module.getStatus(), schema);
localComponentMetadataBuilder.addConfigurations(metaData, configurationsProvider.getAll());
holder.cachedValue = metaData;
return metaData;
}
use of org.gradle.api.artifacts.ModuleVersionIdentifier in project gradle by gradle.
the class DefaultComponentSelectorConverter method getSelector.
@Override
public ModuleVersionSelector getSelector(ComponentSelector selector) {
if (selector instanceof ModuleComponentSelector) {
return DefaultModuleVersionSelector.newSelector((ModuleComponentSelector) selector);
}
if (selector instanceof ProjectComponentSelector) {
ProjectComponentSelector projectSelector = (ProjectComponentSelector) selector;
ProjectComponentIdentifier projectId = componentIdentifierFactory.createProjectComponentIdentifier(projectSelector);
LocalComponentMetadata projectComponent = localComponentRegistry.getComponent(projectId);
if (projectComponent != null) {
ModuleVersionIdentifier moduleVersionId = projectComponent.getModuleVersionId();
return DefaultModuleVersionSelector.newSelector(moduleVersionId.getGroup(), moduleVersionId.getName(), moduleVersionId.getVersion());
}
}
if (selector instanceof LibraryComponentSelector) {
LibraryComponentSelector libraryComponentSelector = (LibraryComponentSelector) selector;
String libraryName = GUtil.elvis(libraryComponentSelector.getLibraryName(), "");
return DefaultModuleVersionSelector.newSelector(libraryComponentSelector.getProjectPath(), libraryName, "undefined");
}
return UNKNOWN_MODULE_VERSION_SELECTOR;
}
use of org.gradle.api.artifacts.ModuleVersionIdentifier in project gradle by gradle.
the class ShortCircuitEmptyConfigurationResolver method emptyGraph.
private void emptyGraph(ConfigurationInternal configuration, ResolverResults results) {
Module module = configuration.getModule();
ModuleVersionIdentifier id = moduleIdentifierFactory.moduleWithVersion(module);
ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
ResolutionResult emptyResult = DefaultResolutionResultBuilder.empty(id, componentIdentifier);
ResolvedLocalComponentsResult emptyProjectResult = new ResolvedLocalComponentsResultGraphVisitor(thisBuild.getCurrentBuild());
results.graphResolved(emptyResult, emptyProjectResult, new EmptyResults());
}
Aggregations