/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion config.compileSdkVersion

    defaultConfig {
        applicationId "org.mozilla.samples.browser"
        minSdkVersion config.minSdkVersion
        targetSdkVersion config.targetSdkVersion
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "engine", "abi"

    productFlavors {
        // GeckoView release channels
        geckoNightly {
            dimension "engine"
        }
        geckoBeta {
            dimension "engine"
        }
        geckoRelease {
            dimension "engine"
        }

        // WebView
        system {
            dimension "engine"
        }

        servo {
            dimension "engine"
        }
        
        // Processor architecture
        arm {
            dimension "abi"
        }
        x86 {
            dimension "abi"
        }
        aarch64 {
            dimension "abi"
        }
        universal {
            dimension "abi"
        }
    }

    variantFilter { variant ->
        if (variant.buildType.name == "release") {
            // This is a sample app that we are not releasing. Save some time and do not build
            // release versions.
            setIgnore(true)
        }

        def flavors = variant.flavors*.name.toString().toLowerCase()
        if (flavors.contains("system") && !flavors.contains("universal")) {
            setIgnore(true)
        }

        if (flavors.contains("gecko") && flavors.contains("universal")) {
            setIgnore(true)
        }

        if (flavors.contains("servo") && !flavors.contains("arm") && !flavors.contains("x86")) {
            setIgnore(true)
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

configurations {
    geckoNightlyArmImplementation {}
    geckoNightlyX86Implementation {}
    geckoNightlyAarch64Implementation {}

    geckoBetaArmImplementation {}
    geckoBetaX86Implementation {}
    geckoBetaAarch64Implementation {}

    geckoReleaseArmImplementation {}
    geckoReleaseX86Implementation {}
    geckoReleaseAarch64Implementation {}

    servoX86Implementation {}
    servoArmImplementation {}
}

dependencies {
    implementation project(':concept-awesomebar')
    implementation project(':concept-fetch')
    implementation project(':concept-engine')
    implementation project(':concept-tabstray')
    implementation project(':concept-toolbar')
    implementation project(':concept-storage')

    implementation project(':browser-awesomebar')
    implementation project(':browser-engine-system')
    implementation project(':browser-domains')
    implementation project(':browser-icons')
    implementation project(':browser-search')
    implementation project(':browser-session')
    implementation project(':browser-tabstray')
    implementation project(':browser-toolbar')
    implementation project(':browser-menu')
    implementation project(':browser-storage-memory')

    implementation project(':lib-fetch-httpurlconnection')

    implementation project(':feature-awesomebar')
    implementation project(':feature-contextmenu')
    implementation project(':feature-customtabs')
    implementation project(':feature-intent')
    implementation project(':feature-readerview')
    implementation project(':feature-search')
    implementation project(':feature-session')
    implementation project(':feature-toolbar')
    implementation project(':feature-tabs')
    implementation project(':feature-prompts')
    implementation project(':feature-findinpage')
    implementation project(':feature-sitepermissions')

    implementation project(':ui-autocomplete')

    implementation project(':support-utils')
    implementation project(':feature-downloads')
    implementation project(':support-ktx')

    servoImplementation project(':browser-engine-servo')
    servoX86Implementation Dependencies.mozilla_servo_x86
    servoArmImplementation Dependencies.mozilla_servo_arm

    geckoNightlyImplementation project(':browser-engine-gecko-nightly')
    geckoNightlyArmImplementation Gecko.geckoview_nightly_arm
    geckoNightlyX86Implementation Gecko.geckoview_nightly_x86
    geckoNightlyAarch64Implementation Gecko.geckoview_nightly_aarch64

    geckoBetaImplementation project(':browser-engine-gecko-beta')
    geckoBetaArmImplementation Gecko.geckoview_beta_arm
    geckoBetaX86Implementation Gecko.geckoview_beta_x86
    geckoBetaAarch64Implementation Gecko.geckoview_beta_aarch64

    geckoReleaseImplementation project(':browser-engine-gecko')
    geckoReleaseArmImplementation Gecko.geckoview_release_arm
    geckoReleaseX86Implementation Gecko.geckoview_release_x86
    geckoReleaseAarch64Implementation Gecko.geckoview_release_aarch64

    implementation Dependencies.support_design

    implementation Dependencies.kotlin_stdlib

    implementation Dependencies.support_appcompat
    implementation Dependencies.support_constraintlayout
}
