use of com.android.build.gradle.tasks.factory.AwbAndroidJavaCompile in project atlas by alibaba.
the class JavacAwbsTask method run.
@TaskAction
void run() throws ExecutionException, InterruptedException {
AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
if (null == atlasDependencyTree) {
return;
}
BaseExtension androidExtension = appVariantOutputContext.getVariantContext().getAppExtension();
boolean isDatabindEnabled = null != androidExtension.getDataBinding() && androidExtension.getDataBinding().isEnabled();
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
ExecutorServicesHelper executorServicesHelper2 = new ExecutorServicesHelper(taskName + "databinding", getLogger(), 1);
List<Runnable> runnables = new ArrayList<>();
List<Runnable> runnables2 = new ArrayList<>();
for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
if (awbBundle.isMBundle) {
continue;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
AwbJavaCompileConfigAction awbJavaCompileConfigAction = new AwbJavaCompileConfigAction(awbBundle, appVariantOutputContext);
AwbAndroidJavaCompile awbJavaCompile = TaskCreater.create(getProject(), awbJavaCompileConfigAction.getName(), awbJavaCompileConfigAction.getType());
awbJavaCompileConfigAction.execute(awbJavaCompile);
awbJavaCompile.execute();
AwbTransform awbTransform = appVariantOutputContext.getAwbTransformMap().get(awbBundle.getName());
awbTransform.addDir(awbJavaCompile.getDestinationDir());
} catch (Throwable e) {
e.printStackTrace();
throw new GradleException("javac " + awbBundle.getName() + " failed");
}
}
};
if (appVariantOutputContext.getVariantContext().isDataBindEnabled(awbBundle)) {
runnables2.add(runnable);
} else {
runnables.add(runnable);
}
}
executorServicesHelper.execute(runnables);
executorServicesHelper2.execute(runnables2);
}
Aggregations