Search in sources :

Example 11 with DefaultTask

use of org.gradle.api.DefaultTask in project atlas by alibaba.

the class MtlParallelTask method run.

@TaskAction
void run() {
    if (null == parallelTask || parallelTask.isEmpty()) {
        return;
    }
    if (concurrent) {
        String taskName = uniqueTaskName;
        if (StringUtils.isEmpty(taskName)) {
            taskName = parallelTask.get(0).getClass().getSimpleName();
        }
        parallelTask.forEach(task -> waitableExecutor.execute((Callable) () -> {
            task.execute();
            return null;
        }));
        try {
            waitableExecutor.waitForTasksWithQuickFail(true);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    } else {
        for (final DefaultTask task : parallelTask) {
            task.execute();
        }
    }
}
Also used : DefaultTask(org.gradle.api.DefaultTask) Callable(java.util.concurrent.Callable) TaskAction(org.gradle.api.tasks.TaskAction)

Example 12 with DefaultTask

use of org.gradle.api.DefaultTask in project atlas by alibaba.

the class MergeManifestAwbsConfigAction 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>();
    AppVariantOutputContext appVariantOutputContext = getAppVariantOutputContext();
    for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
        MergeAwbManifests.ConfigAction configAction = new MergeAwbManifests.ConfigAction(appVariantOutputContext.getScope(), awbBundle, appVariantOutputContext);
        MergeAwbManifests mergeAwbManifests = TaskCreater.create(appVariantContext.getProject(), configAction.getName(), configAction.getType());
        configAction.execute(mergeAwbManifests);
        tasks.add(mergeAwbManifests);
    }
    parallelTask.parallelTask = tasks;
    parallelTask.uniqueTaskName = getName();
}
Also used : TaskConfigAction(com.android.build.gradle.internal.scope.TaskConfigAction) DefaultTask(org.gradle.api.DefaultTask) ArrayList(java.util.ArrayList) AppVariantOutputContext(com.android.build.gradle.internal.api.AppVariantOutputContext) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree)

Example 13 with DefaultTask

use of org.gradle.api.DefaultTask in project atlas by alibaba.

the class MergeAwbsJniFolder 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()) {
        MergeAwbAssets.MergeAwbJniLibFoldersConfigAction mergeAwbJniLibFoldersConfigAction = new MergeAwbAssets.MergeAwbJniLibFoldersConfigAction(appVariantContext, baseVariantOutput, awbBundle);
        MergeAwbAssets mergeTask = TaskCreater.create(appVariantContext.getProject(), mergeAwbJniLibFoldersConfigAction.getName(), mergeAwbJniLibFoldersConfigAction.getType());
        mergeAwbJniLibFoldersConfigAction.execute(mergeTask);
        tasks.add(mergeTask);
    }
    parallelTask.parallelTask = tasks;
    parallelTask.concurrent = false;
    parallelTask.uniqueTaskName = getName();
}
Also used : MergeAwbAssets(com.taobao.android.builder.tasks.app.merge.bundle.MergeAwbAssets) DefaultTask(org.gradle.api.DefaultTask) ArrayList(java.util.ArrayList) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree)

Aggregations

DefaultTask (org.gradle.api.DefaultTask)13 ArrayList (java.util.ArrayList)7 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)6 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)4 Task (org.gradle.api.Task)4 DataBindingBuilder (android.databinding.tool.DataBindingBuilder)2 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)2 MergeAwbAssets (com.taobao.android.builder.tasks.app.merge.bundle.MergeAwbAssets)2 TaskAction (org.gradle.api.tasks.TaskAction)2 AppVariantOutputContext (com.android.build.gradle.internal.api.AppVariantOutputContext)1 TaskConfigAction (com.android.build.gradle.internal.scope.TaskConfigAction)1 DataBindingExportBuildInfoTask (com.android.build.gradle.internal.tasks.databinding.DataBindingExportBuildInfoTask)1 DataBindingProcessLayoutsTask (com.android.build.gradle.internal.tasks.databinding.DataBindingProcessLayoutsTask)1 MergeAwbResource (com.taobao.android.builder.tasks.app.merge.bundle.MergeAwbResource)1 MtlParallelTask (com.taobao.android.builder.tasks.manager.MtlParallelTask)1 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)1 File (java.io.File)1 IOException (java.io.IOException)1 Callable (java.util.concurrent.Callable)1 Describable (org.gradle.api.Describable)1