/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    id("android.recipes.extendingAgp")
}

android {
    namespace = "com.example.android.extendingAgp"
    compileSdk = 35
    defaultConfig {
       minSdk = 21
       targetSdk = 35
    }
    flavorDimensions "version"
    productFlavors {
        demo {
            dimension "version"
            applicationIdSuffix ".demo"
            versionNameSuffix "-demo"
            // this block will configure the "demo" ProductFlavor specific extension defined by the extendingAgp plugin.
            dslExtension {
                productFlavorSettingOne "product_flavor_demo"
            }
        }
        full {
            dimension "version"
            applicationIdSuffix ".full"
            versionNameSuffix "-full"
            // this block will configure the "full" ProductFlavor specific extension defined by the extendingAgp plugin.
            dslExtension {
                productFlavorSettingOne "product_flavor_full"
            }
        }
    }

    buildTypes {
        debug {
            // this block will configure the "debug" build type specific extension defined by the extendingAgp plugin.
            // note that the "release" build type does not have a custom extension defined.
            dslExtension {
                buildTypeSettingOne = "build_type_debug"
            }
        }
    }

    dslExtension {
        settingOne = "project_level_setting_one"
        settingTwo = 1
    }
}

androidComponents {
    onVariants(selector().withBuildType("debug"), { variant ->
        // this configures the "debug" variant specific extension point, the
        // other variants are untouched.
        variant.getExtension(VariantDslExtension.class)
                .variantSettingOne.set("variant_${variant.name}")
    })
}
