Search in sources :

Example 1 with ApplicationVariantImpl

use of com.android.build.gradle.internal.api.ApplicationVariantImpl in project atlas by alibaba.

the class DependencyManager method resolveDependencies.

/**
     * 解析项目的依赖,只对使用官方插件的工程启用,可以兼容solib的功能
     */
public void resolveDependencies() {
    // 如果使用官方的插件并且是app,再做一次依赖仲裁
    if (PluginTypeUtils.usedGooglePlugin(project)) {
        if (androidExtension instanceof AppExtension) {
            final AppExtension appExtension = (AppExtension) androidExtension;
            appExtension.getApplicationVariants().all(new Closure<Object>(this, this) {

                public void doCall(Object applicationVariant) {
                    VariantContext variantContext = new VariantContext((ApplicationVariantImpl) applicationVariant, project, atlasExtension, appExtension);
                    resolveDependencyForConfig(variantContext.getVariantDependency(), false);
                }
            });
        } else if (androidExtension instanceof LibraryExtension) {
            final LibraryExtension libraryExtension = (LibraryExtension) androidExtension;
            libraryExtension.getLibraryVariants().all(new Closure<Object>(this, this) {

                public void doCall(Object libraryVariant) {
                    VariantContext variantContext = new VariantContext((LibraryVariantImpl) libraryVariant, project, atlasExtension, libraryExtension);
                    resolveDependencyForConfig(variantContext.getVariantDependency(), true);
                }
            });
        }
    }
}
Also used : ApplicationVariantImpl(com.android.build.gradle.internal.api.ApplicationVariantImpl) Closure(groovy.lang.Closure) AppExtension(com.android.build.gradle.AppExtension) VariantContext(com.android.build.gradle.internal.api.VariantContext) LibraryExtension(com.android.build.gradle.LibraryExtension)

Example 2 with ApplicationVariantImpl

use of com.android.build.gradle.internal.api.ApplicationVariantImpl 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)

Example 3 with ApplicationVariantImpl

use of com.android.build.gradle.internal.api.ApplicationVariantImpl in project atlas by alibaba.

the class AppVariantContextFactory method getAppVariantContext.

public AppVariantContext getAppVariantContext(Project project, ApplicationVariant applicationVariant) {
    AppVariantContext appVariantContext = appVariantContextMap.get(applicationVariant);
    if (null == appVariantContext) {
        appVariantContext = create(project, (ApplicationVariantImpl) applicationVariant);
        appVariantContextMap.put(applicationVariant, appVariantContext);
    }
    return appVariantContext;
}
Also used : ApplicationVariantImpl(com.android.build.gradle.internal.api.ApplicationVariantImpl) AppVariantContext(com.android.build.gradle.internal.api.AppVariantContext)

Aggregations

ApplicationVariantImpl (com.android.build.gradle.internal.api.ApplicationVariantImpl)3 AppExtension (com.android.build.gradle.AppExtension)1 LibraryExtension (com.android.build.gradle.LibraryExtension)1 AppVariantContext (com.android.build.gradle.internal.api.AppVariantContext)1 VariantContext (com.android.build.gradle.internal.api.VariantContext)1 GlobalScope (com.android.build.gradle.internal.scope.GlobalScope)1 VariantScope (com.android.build.gradle.internal.scope.VariantScope)1 Closure (groovy.lang.Closure)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 GradleException (org.gradle.api.GradleException)1 StopExecutionException (org.gradle.api.tasks.StopExecutionException)1