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   Author: alibaba   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
Source Project: javaide   Author: tranleduy2000   File: ApplicationVariantFactory.java    License: 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 Project: gradle-android-publisher   Author: bluesliverx   File: AndroidPublishTask.java    License: 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 Project: javaide   Author: tranleduy2000   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
Source Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: CustomColorRibbonBuilder.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: RibbonizerExtension.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: RibbonizerExtension.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: RibbonizerExtension.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: RibbonizerExtension.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: RibbonizerExtension.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: GrayRibbonBuilder.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: YellowRibbonBuilder.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: GreenRibbonBuilder.java    License: 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 Project: gradle-android-ribbonizer-plugin   Author: maskarade   File: GrayScaleBuilder.java    License: MIT License 4 votes vote down vote up
@Override
public Consumer<BufferedImage> apply(ApplicationVariant applicationVariant, File iconFile) {
    return new GrayScaleFilter();
}
 
Example #15
Source Project: atlas   Author: alibaba   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   Author: tranleduy2000   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;
}