Search in sources :

Example 1 with DefaultTask

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

the class DataBindingProcessLayoutAwbsConfigAction method execute.

@Override
public void execute(MtlParallelTask parallelTask) {
    super.execute(parallelTask);
    AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(parallelTask.getVariantName());
    if (null == androidDependencyTree) {
        return;
    }
    DataBindingBuilder dataBindingBuilder = new DataBindingBuilder();
    dataBindingBuilder.setPrintMachineReadableOutput(false);
    dataBindingBuilder.setDebugLogEnabled(appVariantContext.getProject().getLogger().isDebugEnabled());
    List<DefaultTask> tasks = new ArrayList<DefaultTask>();
    for (final AwbBundle awbBundle : androidDependencyTree.getAwbBundles()) {
        AwbDataBindingProcessLayoutsConfigAction processLayoutsConfigAction = new AwbDataBindingProcessLayoutsConfigAction(appVariantContext, awbBundle, dataBindingBuilder);
        DataBindingProcessLayoutsTask dataBindingProcessLayoutsTask = TaskCreater.create(appVariantContext.getProject(), processLayoutsConfigAction.getName(), processLayoutsConfigAction.getType());
        processLayoutsConfigAction.execute(dataBindingProcessLayoutsTask);
        tasks.add(dataBindingProcessLayoutsTask);
    }
    parallelTask.parallelTask = tasks;
    parallelTask.uniqueTaskName = getName();
    parallelTask.concurrent = true;
}
Also used : ArrayList(java.util.ArrayList) DefaultTask(org.gradle.api.DefaultTask) DataBindingProcessLayoutsTask(com.android.build.gradle.internal.tasks.databinding.DataBindingProcessLayoutsTask) AndroidDependencyTree(com.taobao.android.builder.dependency.AndroidDependencyTree) DataBindingBuilder(android.databinding.tool.DataBindingBuilder) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle)

Example 2 with DefaultTask

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

the class MtlParallelTask method run.

@TaskAction
void run() throws ExecutionException, InterruptedException {
    if (null == parallelTask || parallelTask.isEmpty()) {
        return;
    }
    if (concurrent) {
        String taskName = uniqueTaskName;
        if (StringUtils.isEmpty(taskName)) {
            taskName = parallelTask.get(0).getClass().getSimpleName();
        }
        ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
        List<Runnable> runnables = new ArrayList<>();
        for (final DefaultTask task : parallelTask) {
            runnables.add(new Runnable() {

                @Override
                public void run() {
                    task.execute();
                }
            });
        }
        executorServicesHelper.execute(runnables);
    } else {
        for (final DefaultTask task : parallelTask) {
            task.execute();
        }
    }
}
Also used : ExecutorServicesHelper(com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper) ArrayList(java.util.ArrayList) DefaultTask(org.gradle.api.DefaultTask) TaskAction(org.gradle.api.tasks.TaskAction)

Example 3 with DefaultTask

use of org.gradle.api.DefaultTask in project openfasttrace-gradle by itsallcode.

the class OpenFastTracePlugin method createTask.

private <T extends DefaultTask> T createTask(Project project, String taskName, Class<T> taskType) {
    final Map<String, Class<T>> taskConfig = singletonMap("type", taskType);
    final Task task = project.task(taskConfig, taskName);
    return taskType.cast(task);
}
Also used : TraceTask(org.itsallcode.openfasttrace.gradle.task.TraceTask) Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask)

Example 4 with DefaultTask

use of org.gradle.api.DefaultTask 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)

Example 5 with DefaultTask

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

the class MergeAssetAwbsConfigAction 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;
        }
        MergeAwbAssets.MergeAwbAssetConfigAction mergeAwbAssetConfigAction = new MergeAwbAssets.MergeAwbAssetConfigAction(appVariantContext, baseVariantOutput, awbBundle);
        MergeAwbAssets mergeTask = TaskCreater.create(appVariantContext.getProject(), mergeAwbAssetConfigAction.getName(), mergeAwbAssetConfigAction.getType());
        mergeAwbAssetConfigAction.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