Search in sources :

Example 16 with VariantScope

use of com.android.build.gradle.internal.scope.VariantScope in project atlas by alibaba.

the class AtlasAppTaskManager method repalceAndroidBuilder.

private void repalceAndroidBuilder(ApplicationVariant applicationVariant) {
    try {
        if (applicationVariant instanceof ApplicationVariantImpl) {
            VariantScope variantScope = ((ApplicationVariantImpl) applicationVariant).getVariantData().getScope();
            GlobalScope globalScope = variantScope.getGlobalScope();
            // ReflectUtils.updateField(globalScope, "androidBuilder", AtlasBuildContext.androidBuilderMap.get(globalScope.getProject()));
            // Field f = ProjectOptions.class.getDeclaredField("booleanOptions");
            // f.setAccessible(true);
            // Map map = (Map) f.get(((ApplicationVariantImpl) applicationVariant).getVariantData().getScope().getGlobalScope().getProjectOptions());
            // map.put(BooleanOption.ENABLE_AAPT2, false);
            AtlasBuildContext.androidBuilderMap.get(globalScope.getProject()).initAapt(globalScope.getProjectOptions());
        }
    } catch (Exception e) {
        logger.error(e, "write globalScope androidBuilder field failed!");
    }
}
Also used : GlobalScope(com.android.build.gradle.internal.scope.GlobalScope) VariantScope(com.android.build.gradle.internal.scope.VariantScope) ApplicationVariantImpl(com.android.build.gradle.internal.api.ApplicationVariantImpl) StopExecutionException(org.gradle.api.tasks.StopExecutionException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException)

Aggregations

VariantScope (com.android.build.gradle.internal.scope.VariantScope)16 File (java.io.File)12 IOException (java.io.IOException)8 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)7 GradleException (org.gradle.api.GradleException)7 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)6 AndroidLibrary (com.android.builder.model.AndroidLibrary)5 BaseVariantOutput (com.android.build.gradle.api.BaseVariantOutput)4 AppVariantOutputContext (com.android.build.gradle.internal.api.AppVariantOutputContext)4 GradleVariantConfiguration (com.android.build.gradle.internal.core.GradleVariantConfiguration)3 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)3 AtlasExtension (com.taobao.android.builder.extension.AtlasExtension)3 JarFile (java.util.jar.JarFile)3 StopExecutionException (org.gradle.api.tasks.StopExecutionException)3 TransformTask (com.android.build.gradle.internal.pipeline.TransformTask)2 BaseVariantOutputData (com.android.build.gradle.internal.variant.BaseVariantOutputData)2 ManifestProcessorTask (com.android.build.gradle.tasks.ManifestProcessorTask)2 MergeManifests (com.android.build.gradle.tasks.MergeManifests)2 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)2 ArrayList (java.util.ArrayList)2