use of com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo in project atlas by alibaba.
the class DependencyResolver method addResolvedDependencyInfo.
/**
* A recursive approach to dependency resolution
*
* @param parentDependency
* @param resolvedDependenciesMap
*/
private void addResolvedDependencyInfo(ResolvedDependencyInfo parentDependency, Multimap<ModuleVersionIdentifier, ResolvedDependencyInfo> resolvedDependenciesMap) {
int indent = parentDependency.getIndent();
ModuleVersionIdentifier identifier = parentDependency.getModuleVersionIdentifier();
Collection<ResolvedDependencyInfo> childDependencies = resolvedDependenciesMap.get(identifier);
// TODO here
for (ResolvedDependencyInfo childDependency : childDependencies) {
if (childDependency.getIndent() > indent) {
// System.out.println(parentDependency + " indent " + indent + "->" + childDependency
// + " indent " + childDependency.getIndent());
parentDependency.getChildren().add(childDependency);
if (childDependency.getIndent() <= 1) {
addResolvedDependencyInfo(childDependency, resolvedDependenciesMap);
}
}
}
}
use of com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo in project atlas by alibaba.
the class AwbGenerator method createAwbBundle.
public AwbBundle createAwbBundle(LibVariantContext libVariantContext) throws IOException {
String variantName = libVariantContext.getVariantName();
AtlasDependencyTree libDependencyTree = AtlasBuildContext.libDependencyTrees.get(variantName);
// TODO 2.3
if (null == libDependencyTree) {
libDependencyTree = new AtlasDepTreeParser(libVariantContext.getProject(), new ExtraModelInfo(new ProjectOptions(libVariantContext.getProject()), null), new HashSet<>()).parseDependencyTree(libVariantContext.getVariantDependency());
AtlasBuildContext.libDependencyTrees.put(variantName, libDependencyTree);
}
Project project = libVariantContext.getProject();
String groupName = (String) project.getGroup();
String name = "";
String version = (String) project.getVersion();
if (project.hasProperty("archivesBaseName")) {
name = (String) project.getProperties().get("archivesBaseName");
} else {
name = project.getName();
}
File explodedDir = project.file(project.getBuildDir().getAbsolutePath() + "/" + FD_INTERMEDIATES + "/exploded-awb/" + computeArtifactPath(groupName, name, version));
FileUtils.deleteDirectory(explodedDir);
MavenCoordinates mavenCoordinates = new MavenCoordinatesImpl(groupName, name, version, "awb", "");
ResolvedDependencyInfo resolvedDependencyInfo = new ResolvedDependencyInfo(groupName, name, version, "awb");
resolvedDependencyInfo.setVariantName(libVariantContext.getVariantName());
AwbBundle awbBundle = new AwbBundle(resolvedDependencyInfo, DependencyConvertUtils.toAndroidLibrary(mavenCoordinates, libVariantContext.getBundleTask().getArchivePath(), explodedDir));
awbBundle.getSoLibraries().addAll(libDependencyTree.getMainBundle().getSoLibraries());
awbBundle.getAndroidLibraries().addAll(libDependencyTree.getMainBundle().getAndroidLibraries());
awbBundle.getJavaLibraries().addAll(libDependencyTree.getMainBundle().getJavaLibraries());
return awbBundle;
}
use of com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo in project atlas by alibaba.
the class AtlasDependencyTree method createDependencyJson.
public DependencyJson createDependencyJson(boolean printFileSize) {
DependencyJson dependencyJson = new DependencyJson();
for (ResolvedDependencyInfo dep : mResolvedDependencies) {
String value = dep.getDependencyString(printFileSize);
if ("awb".equalsIgnoreCase(dep.getType())) {
ArrayList<String> awbDeps = dependencyJson.getAwbs().get(value);
if (null == awbDeps) {
awbDeps = new ArrayList<String>();
}
addChildDependency(awbDeps, dep, printFileSize);
dependencyJson.getAwbs().put(value, awbDeps);
} else {
dependencyJson.getMainDex().add(value);
addChildDependency(dependencyJson.getMainDex(), dep, printFileSize);
}
}
return dependencyJson;
}
use of com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo in project atlas by alibaba.
the class AtlasDependencyTree method addChildDependency.
private void addChildDependency(List<String> deps, ResolvedDependencyInfo dependencyInfo, boolean printFileSize) {
for (ResolvedDependencyInfo child : dependencyInfo.getChildren()) {
String childValue = child.getDependencyString(printFileSize);
deps.add(childValue);
addChildDependency(deps, child, printFileSize);
}
}
use of com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo in project atlas by alibaba.
the class DependencyResolver method resolveAllDependencies.
/**
* Relying on arbitration
*/
private List<ResolvedDependencyInfo> resolveAllDependencies(Multimap<String, ResolvedDependencyInfo> dependenciesMap) {
List<ResolvedDependencyInfo> allResolvedDependencyInfos = new ArrayList<>();
// The post-arbitration dependencies. The structure is the parent class - subclass
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();
// Children are not required to add information to the resolvedDependenciesMap
resolvedDependencyInfo.setChildren(Lists.<ResolvedDependencyInfo>newArrayList());
if (null != parent) {
// If the parent is dependent, then the current dependency is added to the dependency of the parent
resolvedDependenciesMap.put(parent.getModuleVersionIdentifier(), resolvedDependencyInfo);
} else {
// If there is no parent dependency, it is a primary dependency
directDependencies.put(resolvedDependencyInfo.getModuleVersionIdentifier(), resolvedDependencyInfo);
}
}
}
for (ModuleVersionIdentifier key : directDependencies.keySet()) {
ResolvedDependencyInfo resolvedDependencyInfo = directDependencies.get(key);
// Empty the children
resolvedDependencyInfo.setChildren(Lists.<ResolvedDependencyInfo>newArrayList());
addResolvedDependencyInfo(resolvedDependencyInfo, resolvedDependenciesMap);
allResolvedDependencyInfos.add(resolvedDependencyInfo);
}
return allResolvedDependencyInfos;
}
Aggregations