Search in sources :

Example 6 with AwbBundle

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

the class DependencyConvertUtils method toAwbBundle.

public static AwbBundle toAwbBundle(ResolvedDependencyInfo resolvedDependencyInfo) {
    assertType(Type.AWB, resolvedDependencyInfo);
    List<LibraryDependency> dependencies = Lists.newArrayList();
    Collection<JarDependency> jarDependencies = Lists.newArrayList();
    List<SoLibrary> soLibraries = Lists.newArrayList();
    collectChildren(resolvedDependencyInfo, dependencies, jarDependencies, soLibraries);
    AwbBundle awbBundle = new AwbBundle(resolvedDependencyInfo.getResolvedArtifact().getFile(), resolvedDependencyInfo.getExplodedDir(), dependencies, jarDependencies, resolvedDependencyInfo.getGroup() + "-" + resolvedDependencyInfo.getName(), resolvedDependencyInfo.getVariantName(), resolvedDependencyInfo.getGradlePath(), null, convert(resolvedDependencyInfo.getResolvedArtifact()));
    awbBundle.setSoLibraries(soLibraries);
    return awbBundle;
}
Also used : JarDependency(com.android.builder.dependency.JarDependency) LibraryDependency(com.android.builder.dependency.LibraryDependency) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle)

Example 7 with AwbBundle

use of com.taobao.android.builder.dependency.model.AwbBundle 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 8 with AwbBundle

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

the class JavacAwbsTask method run.

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

            @Override
            public void run() {
                try {
                    AwbJavaCompileConfigAction awbJavaCompileConfigAction = new AwbJavaCompileConfigAction(awbBundle, appVariantOutputContext);
                    JavaCompile awbJavaCompile = TaskCreater.create(getProject(), awbJavaCompileConfigAction.getName(), awbJavaCompileConfigAction.getType());
                    awbJavaCompileConfigAction.execute(awbJavaCompile);
                    awbJavaCompile.execute();
                    AwbTransform awbTransform = appVariantOutputContext.getAwbTransformMap().get(awbBundle.getName());
                    awbTransform.setInputDir(awbJavaCompile.getDestinationDir());
                } catch (Throwable e) {
                    e.printStackTrace();
                    throw new GradleException("javac " + awbBundle.getName() + " failed");
                }
            }
        });
    }
    executorServicesHelper.execute(runnables);
}
Also used : ExecutorServicesHelper(com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper) AwbTransform(com.android.build.gradle.internal.api.AwbTransform) GradleException(org.gradle.api.GradleException) ArrayList(java.util.ArrayList) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) JavaCompile(org.gradle.api.tasks.compile.JavaCompile) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 9 with AwbBundle

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

the class MergeResV4Dir method taskAction.

@TaskAction
public void taskAction() throws IOException {
    File resDir = variantScope.getFinalResourcesDir();
    moveFiles(resDir);
    AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
    if (null != androidDependencyTree) {
        for (final AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
            File awbResDir = variantContext.getMergeResources(awbBundle);
            moveFiles(awbResDir);
        }
    }
}
Also used : AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) File(java.io.File) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 10 with AwbBundle

use of com.taobao.android.builder.dependency.model.AwbBundle 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)

Aggregations

AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)25 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)19 ArrayList (java.util.ArrayList)13 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)10 File (java.io.File)10 TaskAction (org.gradle.api.tasks.TaskAction)10 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)6 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)5 DefaultTask (org.gradle.api.DefaultTask)5 GradleException (org.gradle.api.GradleException)5 AndroidLibrary (com.android.builder.model.AndroidLibrary)4 BundleInfo (com.taobao.android.builder.tools.bundleinfo.model.BundleInfo)4 AarBundle (com.taobao.android.builder.dependency.model.AarBundle)3 HashSet (java.util.HashSet)3 DataBindingBuilder (android.databinding.tool.DataBindingBuilder)2 AwbTransform (com.android.build.gradle.internal.api.AwbTransform)2 JarDependency (com.android.builder.dependency.JarDependency)2 LibraryDependency (com.android.builder.dependency.LibraryDependency)2 JavaLibrary (com.android.builder.model.JavaLibrary)2 IOException (java.io.IOException)2