Search in sources :

Example 1 with AwbAndroidJavaCompile

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);
}
Also used : ArrayList(java.util.ArrayList) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree) BaseExtension(com.android.build.gradle.BaseExtension) ExecutorServicesHelper(com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper) AwbAndroidJavaCompile(com.android.build.gradle.tasks.factory.AwbAndroidJavaCompile) AwbTransform(com.android.build.gradle.internal.api.AwbTransform) GradleException(org.gradle.api.GradleException) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

BaseExtension (com.android.build.gradle.BaseExtension)1 AwbTransform (com.android.build.gradle.internal.api.AwbTransform)1 AwbAndroidJavaCompile (com.android.build.gradle.tasks.factory.AwbAndroidJavaCompile)1 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)1 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)1 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)1 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)1 ArrayList (java.util.ArrayList)1 GradleException (org.gradle.api.GradleException)1 TaskAction (org.gradle.api.tasks.TaskAction)1