Search in sources :

Example 36 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree in project atlas by alibaba.

the class AtlasDependencyManager method resolveDependencies.

/**
 * 1 . detect if has awb dependency
 * <p>
 * yes : special process
 * no  : default process
 * <p>
 * 2.  parse to AtlasDependencyTree
 */
public Set<AndroidDependency> resolveDependencies(@NonNull VariantDependencies variantDeps) {
    this.apDependency = resolveApDependencies(variantDeps);
    AtlasDependencyTree atlasDependencyTree = new AtlasDepTreeParser(project, extraModelInfo, awbs).parseDependencyTree(variantDeps);
    sLogger.info("[dependencyTree" + variantDeps.getName() + "] {}", JSON.toJSONString(atlasDependencyTree.getDependencyJson(), true));
    if (PluginTypeUtils.isAppProject(project)) {
        AtlasBuildContext.androidDependencyTrees.put(variantDeps.getName(), atlasDependencyTree);
    } else {
        AtlasBuildContext.libDependencyTrees.put(variantDeps.getName(), atlasDependencyTree);
    }
    // return libsToExplode;
    return new HashSet<>(0);
}
Also used : AtlasDepTreeParser(com.taobao.android.builder.dependency.parser.AtlasDepTreeParser) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree) HashSet(java.util.HashSet)

Example 37 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree in project atlas by alibaba.

the class AtlasDepTreeParser method parseDependencyTree.

public AtlasDependencyTree parseDependencyTree(@NonNull VariantDependencies variantDeps) {
    // 
    String name = variantDeps.getName().toLowerCase();
    if (!name.endsWith("debug") && !name.endsWith("release")) {
        return new AtlasDependencyTree(new ArrayList<>());
    }
    if (!name.equals("debug") && name.endsWith("debug")) {
        flavorName = variantDeps.getName().substring(0, name.length() - 5);
    }
    if (!name.equals("release") && name.endsWith("release")) {
        flavorName = variantDeps.getName().substring(0, name.length() - 6);
    }
    Configuration compileClasspath = variantDeps.getCompileClasspath();
    Configuration runtimeClasspath = variantDeps.getRuntimeClasspath();
    Configuration apiClasspath = variantDeps.getApiElements();
    Configuration configuration = variantDeps.getAnnotationProcessorConfiguration();
    Configuration bundleClasspath = project.getConfigurations().maybeCreate(AtlasPlugin.BUNDLE_COMPILE);
    ensureConfigured(compileClasspath, project);
    ensureConfigured(runtimeClasspath, project);
    ensureConfigured(bundleClasspath, project);
    ensureConfigured(apiClasspath, project);
    ensureConfigured(configuration, project);
    Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts = Maps.newHashMap();
    collectArtifacts(compileClasspath, artifacts);
    collectArtifacts(runtimeClasspath, artifacts);
    collectArtifacts(apiClasspath, artifacts);
    collectArtifacts(bundleClasspath, artifacts);
    collectArtifacts(configuration, artifacts);
    unEnsureConfigured(compileClasspath);
    unEnsureConfigured(runtimeClasspath);
    unEnsureConfigured(bundleClasspath);
    unEnsureConfigured(apiClasspath);
    unEnsureConfigured(configuration);
    // Rely on the group
    DependencyGroup dependencyGroup = new DependencyGroup(compileClasspath, bundleClasspath, artifacts, awbs);
    DependencyResolver dependencyResolver = new DependencyResolver(project, variantDeps, artifacts, dependencyGroup.bundleProvidedMap, dependencyGroup.bundleCompileMap);
    mResolvedDependencies.addAll(dependencyResolver.resolve(dependencyGroup.compileDependencies, true));
    for (DependencyResult dependencyResult : dependencyGroup.bundleDependencies) {
        mResolvedDependencies.addAll(dependencyResolver.resolve(Arrays.asList(dependencyResult), false));
    }
    AtlasDependencyTree atlasDependencyTree = toAtlasDependencyTree();
    check(atlasDependencyTree);
    return atlasDependencyTree;
}
Also used : DependencyResult(org.gradle.api.artifacts.result.DependencyResult) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree) DependencyGroup(com.taobao.android.builder.dependency.parser.helper.DependencyGroup) DependencyResolver(com.taobao.android.builder.dependency.parser.helper.DependencyResolver)

Example 38 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree in project atlas by alibaba.

the class AtlasDepTreeParser method toAtlasDependencyTree.

private AtlasDependencyTree toAtlasDependencyTree() {
    AtlasDependencyTree atlasDependencyTree = new AtlasDependencyTree(mResolvedDependencies);
    // Setting dependency
    for (ResolvedDependencyInfo dependencyInfo : mResolvedDependencies) {
        if (Type.AWB == DependencyConvertUtils.Type.getType(dependencyInfo.getType())) {
            AwbBundle bundle = DependencyConvertUtils.toBundle(dependencyInfo, project);
            // if (apDependencies != null) {
            // Map<ModuleIdentifier, String> awbDependencies = apDependencies.getAwbDependencies(
            // dependencyInfo.getGroup(), dependencyInfo.getName());
            // bundle.setBaseAwbDependencies(awbDependencies);
            // }
            atlasDependencyTree.getAwbBundles().add(bundle);
            collect(dependencyInfo, bundle);
        } else {
            collect(dependencyInfo, atlasDependencyTree.getMainBundle());
        }
    }
    return atlasDependencyTree;
}
Also used : AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree)

Aggregations

AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)38 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)26 File (java.io.File)21 ArrayList (java.util.ArrayList)16 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)13 GradleException (org.gradle.api.GradleException)13 TaskAction (org.gradle.api.tasks.TaskAction)12 IOException (java.io.IOException)11 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)8 AwbTransform (com.android.build.gradle.internal.api.AwbTransform)7 VariantScope (com.android.build.gradle.internal.scope.VariantScope)7 BaseVariantOutput (com.android.build.gradle.api.BaseVariantOutput)6 AppVariantOutputContext (com.android.build.gradle.internal.api.AppVariantOutputContext)6 JarFile (java.util.jar.JarFile)6 BundleInfo (com.taobao.android.builder.tools.bundleinfo.model.BundleInfo)5 AppVariantContext (com.android.build.gradle.internal.api.AppVariantContext)4 DefaultTask (org.gradle.api.DefaultTask)4 TaskContainerAdaptor (com.android.build.gradle.internal.TaskContainerAdaptor)3 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)3 Task (org.gradle.api.Task)3