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;
}
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();
}
}
}
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);
}
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;
}
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();
}
Aggregations