Search in sources :

Example 1 with MtlParallelTask

use of com.taobao.android.builder.tasks.app.MtlParallelTask in project atlas by alibaba.

the class MergeResAwbsConfigAction method execute.

@Override
public void execute(MtlParallelTask parallelTask) {
    super.execute(parallelTask);
    AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(parallelTask.getVariantName());
    if (null == androidDependencyTree) {
        return;
    }
    List<DefaultTask> tasks = new ArrayList<DefaultTask>();
    for (final AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
        MergeAwbResourceConfigAction mergeAwbResourceConfigAction = new MergeAwbResourceConfigAction(appVariantContext, baseVariantOutputData, awbBundle);
        final MergeResources mergeTask = TaskCreater.create(appVariantContext.getProject(), mergeAwbResourceConfigAction.getName(), mergeAwbResourceConfigAction.getType());
        mergeAwbResourceConfigAction.execute(mergeTask);
        tasks.add(mergeTask);
        mergeTask.doLast(new Action<Task>() {

            @Override
            public void execute(Task task) {
                File publicRes = new File(awbBundle.getResFolder(), "values/public.xml");
                if (publicRes.exists()) {
                    try {
                        FileUtils.copyFile(publicRes, new File(mergeTask.getOutputDir(), "values/public.xml"));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }
    parallelTask.parallelTask = tasks;
    parallelTask.uniqueTaskName = getName();
    parallelTask.concurrent = true;
}
Also used : MergeResources(com.android.build.gradle.tasks.MergeResources) MtlParallelTask(com.taobao.android.builder.tasks.app.MtlParallelTask) Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask) MergeAwbResourceConfigAction(com.taobao.android.builder.tasks.bundle.MergeAwbResourceConfigAction) ArrayList(java.util.ArrayList) DefaultTask(org.gradle.api.DefaultTask) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) IOException(java.io.IOException) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) File(java.io.File)

Aggregations

MergeResources (com.android.build.gradle.tasks.MergeResources)1 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)1 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)1 MtlParallelTask (com.taobao.android.builder.tasks.app.MtlParallelTask)1 MergeAwbResourceConfigAction (com.taobao.android.builder.tasks.bundle.MergeAwbResourceConfigAction)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DefaultTask (org.gradle.api.DefaultTask)1 Task (org.gradle.api.Task)1