Search in sources :

Example 1 with MtlParallelTask

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

the class MergeResAwbsConfigAction method execute.

@Override
public void execute(MtlParallelTask parallelTask) {
    super.execute(parallelTask);
    AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(parallelTask.getVariantName());
    if (null == atlasDependencyTree) {
        return;
    }
    List<DefaultTask> tasks = new ArrayList<DefaultTask>();
    for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
        if (awbBundle.isMBundle) {
            continue;
        }
        MergeAwbResource.MergeAwbResourceConfigAction mergeAwbResourceConfigAction = new MergeAwbResource.MergeAwbResourceConfigAction(appVariantContext, baseVariantOutput, awbBundle);
        final MergeAwbResource mergeTask = TaskCreater.create(appVariantContext.getProject(), mergeAwbResourceConfigAction.getName(), mergeAwbResourceConfigAction.getType());
        // mergeTask.getOutputs().cacheIf(new Spec<Task>() {
        // @Override
        // public boolean isSatisfiedBy(Task element) {
        // return false;
        // }
        // });
        mergeTask.setBlameLogFolder(appVariantContext.getAwbBlameLogFolder(awbBundle));
        mergeAwbResourceConfigAction.execute(mergeTask);
        tasks.add(mergeTask);
        mergeTask.doLast(new Action<Task>() {

            @Override
            public void execute(Task task) {
                File publicRes = new File(awbBundle.getAndroidLibrary().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 : MtlParallelTask(com.taobao.android.builder.tasks.manager.MtlParallelTask) Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree) MergeAwbResource(com.taobao.android.builder.tasks.app.merge.bundle.MergeAwbResource) DefaultTask(org.gradle.api.DefaultTask) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) File(java.io.File)

Aggregations

AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)1 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)1 MergeAwbResource (com.taobao.android.builder.tasks.app.merge.bundle.MergeAwbResource)1 MtlParallelTask (com.taobao.android.builder.tasks.manager.MtlParallelTask)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