Package com.android.builder

Examples of com.android.builder.DefaultProductFlavor


        BaseVariantData testedVariantData = null;

        ProductFlavorData defaultConfigData = basePlugin.getDefaultConfigData();

        DefaultProductFlavor defaultConfig = defaultConfigData.getProductFlavor();
        DefaultAndroidSourceSet defaultConfigSourceSet = defaultConfigData.getSourceSet();

        Closure<Void> variantFilterClosure = basePlugin.getExtension().getVariantFilter();

        for (BuildTypeData buildTypeData : buildTypes.values()) {
View Full Code Here


        // assembleTask for this flavor(group), created on demand if needed.
        Task assembleTask = null;

        ProductFlavorData defaultConfigData = basePlugin.getDefaultConfigData();
        DefaultProductFlavor defaultConfig = defaultConfigData.getProductFlavor();
        DefaultAndroidSourceSet defaultConfigSourceSet = defaultConfigData.getSourceSet();

        final List<ConfigurationProvider> variantProviders = Lists.newArrayListWithCapacity(flavorDataList.length + 2);

        Closure<Void> variantFilterClosure = basePlugin.getExtension().getVariantFilter();
        final List<ProductFlavor> productFlavorList = (variantFilterClosure != null) ? Lists.<ProductFlavor>newArrayListWithCapacity(flavorDataList.length) : null;

        for (BuildTypeData buildTypeData : buildTypes.values()) {
            boolean ignore = false;
            if (variantFilterClosure != null) {
                productFlavorList.clear();
                for (ProductFlavorData data : flavorDataList) {
                    productFlavorList.add(data.getProductFlavor());
                }
                variantFilter.reset(defaultConfig, buildTypeData.getBuildType(), productFlavorList);
                variantFilterClosure.call(variantFilter);
                ignore = variantFilter.isIgnore();
            }

            if (!ignore) {
                if (assembleTask == null && flavorDataList.length > 1) {
                    assembleTask = createAssembleTask(flavorDataList);
                    project.getTasks().getByName("assemble").dependsOn(assembleTask);
                }

                /// add the container of dependencies
                // the order of the libraries is important. In descending order:
                // build types, flavors, defaultConfig.
                variantProviders.clear();
                variantProviders.add(buildTypeData);

                VariantConfiguration variantConfig = new VariantConfiguration(
                        defaultConfig,
                        defaultConfigSourceSet,
                        buildTypeData.getBuildType(),
                        buildTypeData.getSourceSet(),
                        variantFactory.getVariantConfigurationType());

                for (ProductFlavorData data : flavorDataList) {
                    String dimensionName = "";
                    DefaultProductFlavor productFlavor = data.getProductFlavor();

                    if (productFlavor instanceof GroupableProductFlavorDsl) {
                        dimensionName = ((GroupableProductFlavorDsl) productFlavor).getFlavorGroup();
                    }
                    variantConfig.addProductFlavor(
                            productFlavor,
                            data.getSourceSet(),
                            dimensionName
                    );
                    variantProviders.add(data.getMainProvider());
                }

                // now add the defaultConfig
                variantProviders.add(basePlugin.getDefaultConfigData().getMainProvider());

                // create the variant and get its internal storage object.
                BaseVariantData variantData = variantFactory.createVariantData(variantConfig);

                NamedDomainObjectContainer<AndroidSourceSet> sourceSetsContainer = extension
                        .getSourceSetsContainer();

                DefaultAndroidSourceSet variantSourceSet = (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate(
                        variantConfig.getFullName());
                variantConfig.setVariantSourceProvider(variantSourceSet);
                // TODO: hmm this won't work
                //variantProviders.add(new ConfigurationProviderImpl(project, variantSourceSet))

                if (flavorDataList.length > 1) {
                    DefaultAndroidSourceSet multiFlavorSourceSet = (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate(variantConfig.getFlavorName());
                    variantConfig.setMultiFlavorSourceProvider(multiFlavorSourceSet);
                    // TODO: hmm this won't work
                    //variantProviders.add(new ConfigurationProviderImpl(project, multiFlavorSourceSet))
                }

                VariantDependencies variantDep = VariantDependencies.compute(
                        project, variantConfig.getFullName(),
                        variantFactory.isVariantPublished(),
                        variantFactory.isLibrary(),
                        variantProviders.toArray(new ConfigurationProvider[variantProviders.size()]));
                variantData.setVariantDependency(variantDep);

                localVariantDataList.add(variantData);

                if (buildTypeData == testData) {
                    testedVariantData = variantData;
                }

                basePlugin.resolveDependencies(variantDep);
                variantConfig.setDependencies(variantDep);

                basePlugin.getVariantDataList().add(variantData);
                variantFactory.createTasks(variantData, null);

                // setup the task dependencies
                // build type
                buildTypeData.getAssembleTask().dependsOn(variantData.assembleTask);
                // each flavor
                for (ProductFlavorData data : flavorDataList) {
                    data.getAssembleTask().dependsOn(variantData.assembleTask);
                }

                // flavor combo
                if (assembleTask != null) {
                    assembleTask.dependsOn(variantData.assembleTask);
                }
            }
        }

        if (testedVariantData != null) {
            VariantConfiguration testedConfig = testedVariantData.getVariantConfiguration();

            // handle test variant
            VariantConfiguration testVariantConfig = new VariantConfiguration(
                    defaultConfig,
                    defaultConfigData.getTestSourceSet(),
                    testData.getBuildType(),
                    null,
                    VariantConfiguration.Type.TEST,
                    testedVariantData.getVariantConfiguration());

            /// add the container of dependencies
            // the order of the libraries is important. In descending order:
            // flavors, defaultConfig. No build type for tests
            List<ConfigurationProvider> testVariantProviders = Lists.newArrayListWithExpectedSize(1 + flavorDataList.length);

            for (ProductFlavorData data : flavorDataList) {
                String dimensionName = "";
                DefaultProductFlavor productFlavor = data.getProductFlavor();

                if (productFlavor instanceof GroupableProductFlavorDsl) {
                    dimensionName = ((GroupableProductFlavorDsl) productFlavor).getFlavorGroup();
                }
                testVariantConfig.addProductFlavor(
View Full Code Here

        BaseVariantData testedVariantData = null;

        ProductFlavorData defaultConfigData = basePlugin.getDefaultConfigData();

        DefaultProductFlavor defaultConfig = defaultConfigData.getProductFlavor();
        DefaultAndroidSourceSet defaultConfigSourceSet = defaultConfigData.getSourceSet();

        Closure<Void> variantFilterClosure = basePlugin.getExtension().getVariantFilter();

        for (BuildTypeData buildTypeData : buildTypes.values()) {
View Full Code Here

        // assembleTask for this flavor(dimension), created on demand if needed.
        Task assembleTask = null;

        ProductFlavorData defaultConfigData = basePlugin.getDefaultConfigData();
        DefaultProductFlavor defaultConfig = defaultConfigData.getProductFlavor();
        DefaultAndroidSourceSet defaultConfigSourceSet = defaultConfigData.getSourceSet();

        final List<ConfigurationProvider> variantProviders = Lists.newArrayListWithCapacity(flavorDataList.length + 2);

        Closure<Void> variantFilterClosure = basePlugin.getExtension().getVariantFilter();
        final List<ProductFlavor> productFlavorList = (variantFilterClosure != null) ? Lists.<ProductFlavor>newArrayListWithCapacity(flavorDataList.length) : null;

        for (BuildTypeData buildTypeData : buildTypes.values()) {
            boolean ignore = false;
            if (variantFilterClosure != null) {
                productFlavorList.clear();
                for (ProductFlavorData data : flavorDataList) {
                    productFlavorList.add(data.getProductFlavor());
                }
                variantFilter.reset(defaultConfig, buildTypeData.getBuildType(), productFlavorList);
                variantFilterClosure.call(variantFilter);
                ignore = variantFilter.isIgnore();
            }

            if (!ignore) {
                if (assembleTask == null && flavorDataList.length > 1) {
                    assembleTask = createAssembleTask(flavorDataList);
                    project.getTasks().getByName("assemble").dependsOn(assembleTask);
                }

                /// add the container of dependencies
                // the order of the libraries is important. In descending order:
                // build types, flavors, defaultConfig.
                variantProviders.clear();
                variantProviders.add(buildTypeData);

                VariantConfiguration variantConfig = new VariantConfiguration(
                        defaultConfig,
                        defaultConfigSourceSet,
                        buildTypeData.getBuildType(),
                        buildTypeData.getSourceSet(),
                        variantFactory.getVariantConfigurationType());

                for (ProductFlavorData data : flavorDataList) {
                    String dimensionName = "";
                    DefaultProductFlavor productFlavor = data.getProductFlavor();

                    if (productFlavor instanceof GroupableProductFlavorDsl) {
                        dimensionName = ((GroupableProductFlavorDsl) productFlavor).getFlavorDimension();
                    }
                    variantConfig.addProductFlavor(
                            productFlavor,
                            data.getSourceSet(),
                            dimensionName
                    );
                    variantProviders.add(data.getMainProvider());
                }

                // now add the defaultConfig
                variantProviders.add(basePlugin.getDefaultConfigData().getMainProvider());

                // create the variant and get its internal storage object.
                BaseVariantData variantData = variantFactory.createVariantData(variantConfig);

                NamedDomainObjectContainer<AndroidSourceSet> sourceSetsContainer = extension
                        .getSourceSetsContainer();

                DefaultAndroidSourceSet variantSourceSet = (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate(
                        variantConfig.getFullName());
                variantConfig.setVariantSourceProvider(variantSourceSet);
                // TODO: hmm this won't work
                //variantProviders.add(new ConfigurationProviderImpl(project, variantSourceSet))

                if (flavorDataList.length > 1) {
                    DefaultAndroidSourceSet multiFlavorSourceSet = (DefaultAndroidSourceSet) sourceSetsContainer.maybeCreate(variantConfig.getFlavorName());
                    variantConfig.setMultiFlavorSourceProvider(multiFlavorSourceSet);
                    // TODO: hmm this won't work
                    //variantProviders.add(new ConfigurationProviderImpl(project, multiFlavorSourceSet))
                }

                VariantDependencies variantDep = VariantDependencies.compute(
                        project, variantConfig.getFullName(),
                        variantFactory.isVariantPublished(),
                        variantFactory.isLibrary(),
                        variantProviders.toArray(new ConfigurationProvider[variantProviders.size()]));
                variantData.setVariantDependency(variantDep);

                localVariantDataList.add(variantData);

                if (buildTypeData == testData) {
                    testedVariantData = variantData;
                }

                basePlugin.resolveDependencies(variantDep);
                variantConfig.setDependencies(variantDep);

                basePlugin.getVariantDataList().add(variantData);
                variantFactory.createTasks(variantData, null);

                // setup the task dependencies
                // build type
                buildTypeData.getAssembleTask().dependsOn(variantData.assembleTask);
                // each flavor
                for (ProductFlavorData data : flavorDataList) {
                    data.getAssembleTask().dependsOn(variantData.assembleTask);
                }

                // flavor combo
                if (assembleTask != null) {
                    assembleTask.dependsOn(variantData.assembleTask);
                }
            }
        }

        if (testedVariantData != null) {
            VariantConfiguration testedConfig = testedVariantData.getVariantConfiguration();

            // handle test variant
            VariantConfiguration testVariantConfig = new VariantConfiguration(
                    defaultConfig,
                    defaultConfigData.getTestSourceSet(),
                    testData.getBuildType(),
                    null,
                    VariantConfiguration.Type.TEST,
                    testedVariantData.getVariantConfiguration());

            /// add the container of dependencies
            // the order of the libraries is important. In descending order:
            // flavors, defaultConfig. No build type for tests
            List<ConfigurationProvider> testVariantProviders = Lists.newArrayListWithExpectedSize(1 + flavorDataList.length);

            for (ProductFlavorData data : flavorDataList) {
                String dimensionName = "";
                DefaultProductFlavor productFlavor = data.getProductFlavor();

                if (productFlavor instanceof GroupableProductFlavorDsl) {
                    dimensionName = ((GroupableProductFlavorDsl) productFlavor).getFlavorDimension();
                }
                testVariantConfig.addProductFlavor(
View Full Code Here

TOP

Related Classes of com.android.builder.DefaultProductFlavor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.