com.android.build.gradle.BaseExtension Java Examples

The following examples show how to use com.android.build.gradle.BaseExtension. 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: FirebaseTestLabPlugin.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
  FirebaseTestLabExtension extension =
      project
          .getExtensions()
          .create("firebaseTestLab", FirebaseTestLabExtension.class, project.getObjects());
  extension.setEnabled(true);
  BaseExtension android = (BaseExtension) project.getExtensions().getByName("android");
  android.testServer(new FirebaseTestServer(project, extension));
}
 
Example #2
Source File: VariantProcessor.java    From Injector with Apache License 2.0 5 votes vote down vote up
VariantProcessor(Project project, BaseVariant variant) {
	this.project = project;
	this.variant = variant;
	this.androidExtension = (BaseExtension) project.getExtensions().getByName("android");
	this.variantName = variant.getName();
	this.variantName = variantName.substring(0, 1).toUpperCase() + variantName.substring(1);
	try {
		projectPackageName = new XmlSlurper().parse(androidExtension.getSourceSets().getByName("main").getManifest()
				.getSrcFile()).getProperty("@package").toString();
	} catch (IOException | SAXException | ParserConfigurationException e) {
		e.printStackTrace();
	}
}
 
Example #3
Source File: WMRouterPlugin.java    From WMRouter with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    WMRouterExtension extension = project.getExtensions()
            .create(Const.NAME, WMRouterExtension.class);

    WMRouterLogger.info("register transform");
    project.getExtensions().findByType(BaseExtension.class)
            .registerTransform(new WMRouterTransform());

    project.afterEvaluate(p -> WMRouterLogger.setConfig(extension));
}
 
Example #4
Source File: ApiObjectFactory.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public ApiObjectFactory(
        @NonNull AndroidBuilder androidBuilder,
        @NonNull BaseExtension extension,
        @NonNull VariantFactory variantFactory,
        @NonNull Instantiator instantiator) {
    this.androidBuilder = androidBuilder;
    this.extension = extension;
    this.variantFactory = variantFactory;
    this.instantiator = instantiator;
}
 
Example #5
Source File: RouterModulePlugin.java    From EasyRouter with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    BaseExtension androidExtension = (BaseExtension) project.getExtensions().getByName("android");

    if (project.getPlugins().findPlugin("com.android.application") != null) {
        androidExtension.registerTransform(new ApplicationTransform());
    } else if (project.getPlugins().findPlugin("com.android.library") != null) {
        androidExtension.registerTransform(new LibraryTransform(project));
    } else {
        throw new ProjectConfigurationException("Need android application/library plugin to be applied first", null);
    }
}
 
Example #6
Source File: JavacAwbsTask.java    From atlas with Apache License 2.0 4 votes vote down vote up
@TaskAction
void run() throws ExecutionException, InterruptedException {

    AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());

    if (null == atlasDependencyTree) {
        return;
    }

    BaseExtension androidExtension = appVariantOutputContext.getVariantContext().getAppExtension();
    boolean isDatabindEnabled = null != androidExtension.getDataBinding() && androidExtension.getDataBinding()
        .isEnabled();

    ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(),0);
    ExecutorServicesHelper executorServicesHelper2 = new ExecutorServicesHelper(taskName+"databinding", getLogger(),
                                                                                1);
    List<Runnable> runnables = new ArrayList<>();
    List<Runnable> runnables2 = new ArrayList<>();

    for (final AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
        if (awbBundle.isMBundle){
            continue;
        }
        Runnable runnable = new Runnable() {
            @Override
            public void run() {

                try {

                    AwbJavaCompileConfigAction awbJavaCompileConfigAction = new AwbJavaCompileConfigAction(
                        awbBundle, appVariantOutputContext);

                    AwbAndroidJavaCompile awbJavaCompile = TaskCreater.create(getProject(),
                                                                    awbJavaCompileConfigAction.getName(),
                                                                    awbJavaCompileConfigAction.getType());

                    awbJavaCompileConfigAction.execute(awbJavaCompile);

                    awbJavaCompile.execute();

                    AwbTransform awbTransform = appVariantOutputContext.getAwbTransformMap().get(
                        awbBundle.getName());

                    awbTransform.addDir(awbJavaCompile.getDestinationDir());

                } catch (Throwable e) {
                    e.printStackTrace();
                    throw new GradleException("javac " + awbBundle.getName() + " failed");
                }

            }
        };

        if (appVariantOutputContext.getVariantContext().isDataBindEnabled(awbBundle)){
            runnables2.add(runnable);
        }else {
            runnables.add(runnable);
        }

    }

    executorServicesHelper.execute(runnables);
    executorServicesHelper2.execute(runnables2);

}
 
Example #7
Source File: AtlasFeatureTaskManager.java    From atlas with Apache License 2.0 4 votes vote down vote up
public AtlasFeatureTaskManager(AtlasBuilder androidBuilder, BaseExtension androidExtension, Project project, AtlasExtension atlasExtension) {
    super(androidBuilder, androidExtension, project, atlasExtension);
    this.featureExtension = (FeatureExtension) androidExtension;
}