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

The following examples show how to use com.android.build.gradle.api.ApplicationVariant. 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 File: AtlasAppTaskManager.java    From atlas with 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
Source File: ApplicationVariantFactory.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: AndroidPublishTask.java    From gradle-android-publisher with Apache License 2.0 5 votes vote down vote up
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 File: AppExtension.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addVariant(BaseVariant variant) {
    applicationVariantList.add((ApplicationVariant) variant);
}
 
Example #5
Source File: CustomColorRibbonBuilder.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), Color.decode(nm));
}
 
Example #6
Source File: RibbonizerExtension.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
public Consumer<BufferedImage> grayScaleFilter(ApplicationVariant variant, File iconFile) {
    return new GrayScaleBuilder().apply(variant, iconFile);
}
 
Example #7
Source File: RibbonizerExtension.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
public Consumer<BufferedImage> grayRibbonFilter(ApplicationVariant variant, File iconFile) {
    return new GrayRibbonBuilder().apply(variant, iconFile);
}
 
Example #8
Source File: RibbonizerExtension.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
public Consumer<BufferedImage> yellowRibbonFilter(ApplicationVariant variant, File iconFile) {
    return new YellowRibbonBuilder().apply(variant, iconFile);
}
 
Example #9
Source File: RibbonizerExtension.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
public Consumer<BufferedImage> greenRibbonFilter(ApplicationVariant variant, File iconFile) {
    return new GreenRibbonBuilder().apply(variant, iconFile);
}
 
Example #10
Source File: RibbonizerExtension.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
public Consumer<BufferedImage> customColorRibbonFilter(ApplicationVariant variant, File iconFile, String nm) {
    return new CustomColorRibbonBuilder(nm).apply(variant, iconFile);
}
 
Example #11
Source File: GrayRibbonBuilder.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
 
Example #12
Source File: YellowRibbonBuilder.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
 
Example #13
Source File: GreenRibbonBuilder.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
@Override
public Consumer<BufferedImage> apply(ApplicationVariant variant, File iconFile) {
    return new ColorRibbonFilter(variant.getBuildType().getName(), COLOR);
}
 
Example #14
Source File: GrayScaleBuilder.java    From gradle-android-ribbonizer-plugin with MIT License 4 votes vote down vote up
@Override
public Consumer<BufferedImage> apply(ApplicationVariant applicationVariant, File iconFile) {
    return new GrayScaleFilter();
}
 
Example #15
Source File: AppVariantContextFactory.java    From atlas with 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 File: AppExtension.java    From javaide with 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;
}