Search in sources :

Example 1 with AarBundle

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

the class DependencyConvertUtils method collectChildren.

/**
     * 收集子集合
     *
     * @param dependencyInfo
     * @param dependencies
     * @param jarDependencies
     * @param soLibraries
     */
private static void collectChildren(ResolvedDependencyInfo dependencyInfo, List<LibraryDependency> dependencies, Collection<JarDependency> jarDependencies, List<SoLibrary> soLibraries) {
    List<ResolvedDependencyInfo> children = dependencyInfo.getChildren();
    for (ResolvedDependencyInfo child : children) {
        switch(Type.getType(child.getType())) {
            case AAR:
                AarBundle aarBundle = toAarBundle(child, false);
                dependencies.add(aarBundle);
                collectChildren(child, dependencies, jarDependencies, soLibraries);
                break;
            case JAR:
                JarDependency jarInfo = toJarDependency(child, false);
                jarDependencies.add(jarInfo);
                collectChildren(child, dependencies, jarDependencies, soLibraries);
                break;
            case SOLIB:
                SoLibrary soLibrary = toSoLibrary(child);
                soLibraries.add(soLibrary);
                break;
            default:
                break;
        }
    }
}
Also used : JarDependency(com.android.builder.dependency.JarDependency) AarBundle(com.taobao.android.builder.dependency.model.AarBundle) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary)

Example 2 with AarBundle

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

the class DependencyConvertUtils method toAarBundle.

/**
     * 将依赖类型转换为LibraryDependencyImpl
     *
     * @param resolvedDependencyInfo
     * @return
     */
private static AarBundle toAarBundle(ResolvedDependencyInfo resolvedDependencyInfo, boolean containChild) {
    assertType(Type.AAR, resolvedDependencyInfo);
    List<LibraryDependency> dependencies = Lists.newArrayList();
    Collection<JarDependency> jarDependencies = Lists.newArrayList();
    List<SoLibrary> soLibraries = Lists.newArrayList();
    if (containChild) {
        collectChildren(resolvedDependencyInfo, dependencies, jarDependencies, soLibraries);
    }
    AarBundle aarBundle = new AarBundle(resolvedDependencyInfo.getResolvedArtifact().getFile(), resolvedDependencyInfo.getExplodedDir(), dependencies, jarDependencies, resolvedDependencyInfo.getGroup() + "-" + resolvedDependencyInfo.getName(), resolvedDependencyInfo.getVariantName(), resolvedDependencyInfo.getGradlePath(), null, convert(resolvedDependencyInfo.getResolvedArtifact()));
    aarBundle.setSoLibraries(soLibraries);
    return aarBundle;
}
Also used : JarDependency(com.android.builder.dependency.JarDependency) LibraryDependency(com.android.builder.dependency.LibraryDependency) AarBundle(com.taobao.android.builder.dependency.model.AarBundle) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary)

Example 3 with AarBundle

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

the class DependencyTree method toAndroidDependency.

/**
     * 转换为Android的依赖
     *
     * @return
     */
public AndroidDependencyTree toAndroidDependency() {
    AndroidDependencyTree androidDependencyTree = new AndroidDependencyTree(mResolvedDependencies);
    for (ResolvedDependencyInfo dependencyInfo : mResolvedDependencies) {
        switch(DependencyConvertUtils.Type.getType(dependencyInfo.getType())) {
            case AAR:
                AarBundle aarBundle = DependencyConvertUtils.toAarBundle(dependencyInfo);
                androidDependencyTree.getAarBundles().add(aarBundle);
                for (AndroidLibrary libraryDependency : aarBundle.getLibraryDependencies()) {
                    if (libraryDependency instanceof AarBundle) {
                        androidDependencyTree.getAarBundles().add((AarBundle) libraryDependency);
                    }
                }
                androidDependencyTree.getJars().addAll(aarBundle.getJavaDependencies());
                androidDependencyTree.getSoLibraries().addAll(aarBundle.getSoLibraries());
                break;
            case AWB:
                AwbBundle awbBundle = DependencyConvertUtils.toAwbBundle(dependencyInfo);
                androidDependencyTree.getAwbBundles().add(awbBundle);
                break;
            case JAR:
                JavaLibrary jarInfo = DependencyConvertUtils.toJarDependency(dependencyInfo);
                androidDependencyTree.getJars().add(jarInfo);
                androidDependencyTree.getJars().addAll(jarInfo.getDependencies());
                break;
            case SOLIB:
                SoLibrary soLibrary = DependencyConvertUtils.toSoLibrary(dependencyInfo);
                androidDependencyTree.getSoLibraries().add(soLibrary);
                break;
            case APK:
                ApkLibrary apkLibrary = DependencyConvertUtils.toApkLibrary(dependencyInfo);
                androidDependencyTree.getApkLibraries().add(apkLibrary);
                break;
            case AP:
                ApLibrary apLibrary = DependencyConvertUtils.toApLibrary(dependencyInfo);
                androidDependencyTree.getApLibraries().add(apLibrary);
                break;
            default:
                break;
        }
    }
    return androidDependencyTree;
}
Also used : JavaLibrary(com.android.builder.model.JavaLibrary) AndroidLibrary(com.android.builder.model.AndroidLibrary) AarBundle(com.taobao.android.builder.dependency.model.AarBundle) ApLibrary(com.taobao.android.builder.dependency.model.ApLibrary) ApkLibrary(com.taobao.android.builder.dependency.model.ApkLibrary) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary)

Example 4 with AarBundle

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

the class PrepareAwbTask method run.

@TaskAction
void run() throws ExecutionException, InterruptedException, IOException, DocumentException {
    AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
    if (null == androidDependencyTree) {
        return;
    }
    ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
    List<Runnable> runnables = new ArrayList<>();
    Set<SoLibrary> soLibraries = androidDependencyTree.getALLSoLibDependencies();
    for (final SoLibrary soLibrary : soLibraries) {
        runnables.add(new Runnable() {

            @Override
            public void run() {
                prepare(soLibrary.getSoLibFile(), soLibrary.getFolder(), false);
            }
        });
    }
    executorServicesHelper.execute(runnables);
    runnables.clear();
    List<AwbBundle> awbBundles = androidDependencyTree.getAwbBundles();
    for (final AwbBundle awbBundle : awbBundles) {
        runnables.add(new Runnable() {

            @Override
            public void run() {
                prepare(awbBundle.getBundle(), awbBundle.getFolder(), true);
            }
        });
    }
    executorServicesHelper.execute(runnables);
    runnables.clear();
    Set<AarBundle> aarBundles = androidDependencyTree.getALLAarDependencies();
    for (final AarBundle aarBundle : aarBundles) {
        runnables.add(new Runnable() {

            @Override
            public void run() {
                prepare(aarBundle.getBundle(), aarBundle.getFolder(), true);
            }
        });
    }
    executorServicesHelper.execute(runnables);
    runnables.clear();
}
Also used : ExecutorServicesHelper(com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper) ArrayList(java.util.ArrayList) AarBundle(com.taobao.android.builder.dependency.model.AarBundle) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 5 with AarBundle

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

the class AwoDependency method parseDependency.

public void parseDependency(AndroidDependencyTree libDependencyTree, AwbBundle awbBundle) {
    List<SoLibrary> soLibraries = new ArrayList<SoLibrary>();
    for (SoLibrary soLibrary : libDependencyTree.getSoLibraries()) {
        if (isCompileDependency(soLibrary.getResolvedCoordinates())) {
            soLibraries.add(soLibrary);
        }
    }
    List aarBundles = new ArrayList<>();
    for (AarBundle aarBundle : libDependencyTree.getAarBundles()) {
        if (isCompileDependency(aarBundle.getResolvedCoordinates())) {
            aarBundles.add(aarBundle);
        }
    }
    List jarInfos = new ArrayList<JavaLibrary>();
    for (JavaLibrary jarInfo : libDependencyTree.getJars()) {
        if (isCompileDependency(jarInfo.getResolvedCoordinates())) {
            jarInfos.add(jarInfo);
        }
    }
    awbBundle.getSoLibraries().addAll(soLibraries);
    awbBundle.getLibraryDependencies().addAll(aarBundles);
    awbBundle.getJavaDependencies().addAll(jarInfos);
}
Also used : JavaLibrary(com.android.builder.model.JavaLibrary) ArrayList(java.util.ArrayList) AarBundle(com.taobao.android.builder.dependency.model.AarBundle) ArrayList(java.util.ArrayList) List(java.util.List) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary)

Aggregations

AarBundle (com.taobao.android.builder.dependency.model.AarBundle)6 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)6 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)3 JarDependency (com.android.builder.dependency.JarDependency)2 AndroidLibrary (com.android.builder.model.AndroidLibrary)2 JavaLibrary (com.android.builder.model.JavaLibrary)2 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)2 ArrayList (java.util.ArrayList)2 TaskAction (org.gradle.api.tasks.TaskAction)2 LibraryDependency (com.android.builder.dependency.LibraryDependency)1 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)1 ApLibrary (com.taobao.android.builder.dependency.model.ApLibrary)1 ApkLibrary (com.taobao.android.builder.dependency.model.ApkLibrary)1 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)1 List (java.util.List)1