Search in sources :

Example 11 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree 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)

Example 12 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree 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)

Example 13 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree in project atlas by alibaba.

the class MergeResV4Dir method taskAction.

@TaskAction
public void taskAction() throws IOException {
    File resDir = variantScope.getFinalResourcesDir();
    moveFiles(resDir);
    AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
    if (null != atlasDependencyTree) {
        for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
            File awbResDir = variantContext.getMergeResources(awbBundle);
            moveFiles(awbResDir);
        }
    }
}
Also used : AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) File(java.io.File) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 14 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree in project atlas by alibaba.

the class AppVariantOutputContext method getAwbTransformMap.

public synchronized Map<String, AwbTransform> getAwbTransformMap() {
    // TODO
    if (awbTransformMap.isEmpty()) {
        AtlasDependencyTree dependencyTree = AtlasBuildContext.androidDependencyTrees.get(variantContext.getVariantName());
        for (AwbBundle awbBundle : dependencyTree.getAwbBundles()) {
            // Generate the AwbTransform object
            AwbTransform awbTransform = new AwbTransform(awbBundle);
            // awbTransform.setInputDir(awbJavaCompile.getDestinationDir());
            // ADD R.class
            awbTransform.getInputLibraries().addAll(awbBundle.getLibraryJars());
            // awbTransform.getInputLibraries().addAll(appVariantOutputContext.getJAwbavaOutputDir
            // (awbBundle));
            awbTransformMap.put(awbBundle.getName(), awbTransform);
        }
    }
    return awbTransformMap;
}
Also used : AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree)

Example 15 with AtlasDependencyTree

use of com.taobao.android.builder.dependency.AtlasDependencyTree in project atlas by alibaba.

the class AtlasProguardHelper method applyBundleInOutConfigration.

public static File applyBundleInOutConfigration(final AppVariantContext appVariantContext, ProGuardTransform proGuardTransform) {
    VariantScope variantScope = appVariantContext.getScope();
    GlobalScope globalScope = variantScope.getGlobalScope();
    File proguardOut = new File(Joiner.on(File.separatorChar).join(String.valueOf(globalScope.getBuildDir()), FD_OUTPUTS, "mapping", variantScope.getVariantConfiguration().getDirName()));
    File awbInOutConfig = new File(proguardOut, "awb_inout_config.cfg");
    // Add awb configuration
    AtlasDependencyTree dependencyTree = AtlasBuildContext.androidDependencyTrees.get(variantScope.getVariantConfiguration().getFullName());
    if (dependencyTree.getAwbBundles().size() > 0) {
        BaseVariantOutput vod = (BaseVariantOutput) appVariantContext.getVariantOutputData().iterator().next();
        AppVariantOutputContext appVariantOutputContext = appVariantContext.getAppVariantOutputContext(ApkDataUtils.get(vod));
        File awbObfuscatedDir = new File(globalScope.getIntermediatesDir(), "/classes-proguard/" + variantScope.getVariantConfiguration().getDirName());
        AwbProguardConfiguration awbProguardConfiguration = new AwbProguardConfiguration(appVariantOutputContext.getAwbTransformMap().values(), awbObfuscatedDir, appVariantOutputContext);
        try {
            configs = awbProguardConfiguration.printConfigFile(awbInOutConfig);
        } catch (IOException e) {
            throw new GradleException("", e);
        }
        proGuardTransform.setConfigurationFiles(appVariantContext.getScope().getGlobalScope().getProject().files(awbInOutConfig));
    }
    return awbInOutConfig;
}
Also used : GlobalScope(com.android.build.gradle.internal.scope.GlobalScope) BaseVariantOutput(com.android.build.gradle.api.BaseVariantOutput) VariantScope(com.android.build.gradle.internal.scope.VariantScope) GradleException(org.gradle.api.GradleException) AppVariantOutputContext(com.android.build.gradle.internal.api.AppVariantOutputContext) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) File(java.io.File) AtlasDependencyTree(com.taobao.android.builder.dependency.AtlasDependencyTree)

Aggregations

AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)38 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)26 File (java.io.File)21 ArrayList (java.util.ArrayList)16 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)13 GradleException (org.gradle.api.GradleException)13 TaskAction (org.gradle.api.tasks.TaskAction)12 IOException (java.io.IOException)11 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)8 AwbTransform (com.android.build.gradle.internal.api.AwbTransform)7 VariantScope (com.android.build.gradle.internal.scope.VariantScope)7 BaseVariantOutput (com.android.build.gradle.api.BaseVariantOutput)6 AppVariantOutputContext (com.android.build.gradle.internal.api.AppVariantOutputContext)6 JarFile (java.util.jar.JarFile)6 BundleInfo (com.taobao.android.builder.tools.bundleinfo.model.BundleInfo)5 AppVariantContext (com.android.build.gradle.internal.api.AppVariantContext)4 DefaultTask (org.gradle.api.DefaultTask)4 TaskContainerAdaptor (com.android.build.gradle.internal.TaskContainerAdaptor)3 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)3 Task (org.gradle.api.Task)3