Java Code Examples for com.android.build.gradle.api.ApplicationVariant

The following examples show how to use com.android.build.gradle.api.ApplicationVariant. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: atlas   Source File: AtlasAppTaskManager.java    License: Apache License 2.0 6 votes vote down vote up
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!");
        }
    }
 
Example 2
@Override
@NonNull
public ApplicationVariant createVariantApi(
        @NonNull BaseVariantData<? extends BaseVariantOutputData> variantData,
        @NonNull ReadOnlyObjectProvider readOnlyObjectProvider) {
    // create the base variant object.
    ApplicationVariantImpl variant = instantiator.newInstance(
            ApplicationVariantImpl.class,
            variantData,
            androidBuilder,
            readOnlyObjectProvider);

    // now create the output objects
    createApkOutputApiObjects(instantiator, variantData, variant);

    return variant;
}
 
Example 3
private File getApkFile(AndroidPublisherExtension publisherExtension) {
	String variantName = publisherExtension.getVariantName();
	DomainObjectSet<ApplicationVariant> variants = getProject().getExtensions().getByType(AppExtension.class).getApplicationVariants();
	ApplicationVariant variant = null;
	getLogger().info(String.format("Looking for %s variant in outputs", variantName));
	for (ApplicationVariant v : variants) {
		getLogger().debug(String.format("Found variant %s", v.getName()));
		if (v.getName().equals(variantName)) {
			getLogger().debug(String.format("Variant %s will be used", variantName));
			variant = v;
			break;
		}
	}
	if (variant == null) {
		throw new InvalidUserDataException(String.format(
				"Cannot find %s variant for android configuration", variantName));
	}

	for(BaseVariantOutput output : variant.getOutputs()) {
		getLogger().debug(String.format("Found output %s (%s)", output.getName(), output.getBaseName()));
		if (output!=null) {
			getLogger().debug(String.format("Output %s will be used", output.getName()));
			return output.getOutputFile();
		}
	}
	throw new InvalidUserDataException(String.format(
			"Cannot find APK output file for %s variant", variantName));
}
 
Example 4
Source Project: javaide   Source File: AppExtension.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addVariant(BaseVariant variant) {
    applicationVariantList.add((ApplicationVariant) variant);
}
 
Example 5
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), Color.decode(nm));
}
 
Example 6
public Consumer<BufferedImage> grayScaleFilter(ApplicationVariant variant, File iconFile) {
    return new GrayScaleBuilder().apply(variant, iconFile);
}
 
Example 7
public Consumer<BufferedImage> grayRibbonFilter(ApplicationVariant variant, File iconFile) {
    return new GrayRibbonBuilder().apply(variant, iconFile);
}
 
Example 8
public Consumer<BufferedImage> yellowRibbonFilter(ApplicationVariant variant, File iconFile) {
    return new YellowRibbonBuilder().apply(variant, iconFile);
}
 
Example 9
public Consumer<BufferedImage> greenRibbonFilter(ApplicationVariant variant, File iconFile) {
    return new GreenRibbonBuilder().apply(variant, iconFile);
}
 
Example 10
public Consumer<BufferedImage> customColorRibbonFilter(ApplicationVariant variant, File iconFile, String nm) {
    return new CustomColorRibbonBuilder(nm).apply(variant, iconFile);
}
 
Example 11
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
 
Example 12
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
 
Example 13
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
 
Example 14
@Override
public Consumer<BufferedImage> apply(ApplicationVariant applicationVariant, File iconFile) {
    return new GrayScaleFilter();
}
 
Example 15
Source Project: atlas   Source File: AppVariantContextFactory.java    License: Apache License 2.0 3 votes vote down vote up
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;

    }
 
Example 16
Source Project: javaide   Source File: AppExtension.java    License: GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the list of Application variants. Since the collections is built after evaluation, it
 * should be used with Gradle's <code>all</code> iterator to process future items.
 */
public DefaultDomainObjectSet<ApplicationVariant> getApplicationVariants() {
    return applicationVariantList;
}