com.android.build.gradle.AppExtension Java Examples

The following examples show how to use com.android.build.gradle.AppExtension. 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: InjectorPlugin.java    From Injector with Apache License 2.0 6 votes vote down vote up
@Override
public void apply(@NotNull Project target) {
	this.project = target;
	createExtension();
	createConfiguration();
	createExtractAARsTask();
	target.afterEvaluate(project1 -> {
		System.out.println("After evaluate");
		resolveArtifacts();
		if (jars.isEmpty() && aars.isEmpty()) {
			return;
		}
		Utils.removeOldArtifacts(jars);
		Utils.removeOldArtifacts(aars);

		Object extension = project1.getExtensions().getByName("android");
		if (extension instanceof LibraryExtension) {
			((LibraryExtension) extension).getLibraryVariants().all(this::processVariant);
		} else if (extension instanceof AppExtension) {
			((AppExtension) extension).getApplicationVariants().all(this::processVariant);
		}
	});
}
 
Example #2
Source File: ShrinkerPlugin.java    From shrinker with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    if (!project.getPlugins().hasPlugin(AppPlugin.class)) {
        throw new UnsupportedOperationException("Plugin 'shrinker' can only apply with 'com.android.application'");
    }
    AppExtension android = project.getExtensions().getByType(AppExtension.class);
    ShrinkerExtension config = project.getExtensions().create("shrinker", ShrinkerExtension.class);
    android.registerTransform(new InlineRTransform(config));
}
 
Example #3
Source File: AppVariantContextFactory.java    From atlas with Apache License 2.0 5 votes vote down vote up
@NotNull
public AppVariantContext create(Project project, ApplicationVariantImpl applicationVariant) {

    AppVariantContext appVariantContext;
    AppExtension appExtension = project.getExtensions().getByType(AppExtension.class);

    AtlasExtension atlasExtension = project.getExtensions().getByType(AtlasExtension.class);

    appVariantContext = new AppVariantContext(applicationVariant, project,
                                              atlasExtension, appExtension);
    return appVariantContext;
}
 
Example #4
Source File: AppVariantContext.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AppVariantContext(ApplicationVariantImpl applicationVariant, Project project, AtlasExtension atlasExtension,
                         AppExtension appExtension) {

    super(applicationVariant, project, atlasExtension, appExtension);
    this.applicationVariant = applicationVariant;
    this.variantData = (ApplicationVariantData) applicationVariant.getVariantData();
    this.scope = this.variantData.getScope();
}
 
Example #5
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 #6
Source File: DataLoaderPlugin.java    From DataLoader with Apache License 2.0 4 votes vote down vote up
private void addTransform(Project project) {
    AppExtension appExtension = project.getExtensions().findByType(AppExtension.class);
    appExtension.registerTransform(new DataLoaderTransform(project));
}
 
Example #7
Source File: AtlasAppTaskManager.java    From atlas with Apache License 2.0 4 votes vote down vote up
public AtlasAppTaskManager(AtlasBuilder androidBuilder, AppExtension appExtension, Project project,
                           AtlasExtension atlasExtension) {
    super(androidBuilder, appExtension, project, atlasExtension);
    this.appExtension = appExtension;
}
 
Example #8
Source File: DeviceFarmPluginTest.java    From aws-device-farm-gradle-plugin with Apache License 2.0 3 votes vote down vote up
@Test
public void deviceFarmPluginAddsTestServerToProject() {

    gradleProject.getPluginManager().apply("com.android.application");
    gradleProject.getPluginManager().apply("devicefarm");

    assertTrue(((AppExtension) gradleProject.getExtensions().findByName("android")).getTestServers().get(0)
            instanceof DeviceFarmServer);

}