/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import com.facebook.fresco.buildsrc.Deps
import com.facebook.fresco.buildsrc.GradleDeps
import com.facebook.fresco.buildsrc.SampleDeps
import com.facebook.fresco.buildsrc.TestDeps

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

kotlin {
    jvmToolchain(11)
}

android {
    ndkVersion GradleDeps.Native.version

    buildToolsVersion FrescoConfig.buildToolsVersion
    compileSdkVersion FrescoConfig.compileSdkVersion

    namespace "com.facebook.fresco.samples.showcase"

    defaultConfig {
        applicationId "com.facebook.fresco.samples.showcase"
        minSdkVersion FrescoConfig.samplesMinSdkVersion
        targetSdkVersion FrescoConfig.targetSdkVersion
        versionCode 1
        versionName "${VERSION_NAME}"

        testApplicationId "com.facebook.fresco.samples.showcase.test"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        vectorDrawables.useSupportLibrary = true // needed for tinting

        multiDexEnabled = true
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-showcase.pro'
        }
        debug {
            minifyEnabled false
        }
        instrumentation {
            initWith debug
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-showcase.pro'
            testProguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-showcase.pro', 'proguard-test.pro'
            matchingFallbacks = ['debug']
        }
    }

    testBuildType "instrumentation"

    flavorDimensions "main"
    productFlavors {
        normal {
            dimension "main"
        }
        fast {
            dimension "main"
            minSdkVersion FrescoConfig.minSdkVersion
        }
        internal {
            dimension "main"
        }
    }

    lintOptions {
        warning 'InvalidPackage'
        abortOnError false
    }

    splits {
        abi {
            enable true
            reset()
            include 'x86', 'x86_64', 'arm64-v8a', 'armeabi-v7a'
            universalApk false
        }
    }

    buildFeatures {
        viewBinding true
        buildConfig = true
    }
}

dependencies {
    compileOnly Deps.jsr305
    compileOnly Deps.inferAnnotation
    compileOnly Deps.javaxAnnotation

    implementation SampleDeps.AndroidX.appcompat
    implementation SampleDeps.AndroidX.preference
    implementation SampleDeps.AndroidX.recyclerview
    implementation SampleDeps.AndroidX.cardview

    implementation SampleDeps.Google.material
    implementation Deps.Tools.Stetho.okhttp3

    implementation project(':animated-base')
    implementation project(':animated-gif')
    implementation project(':animated-gif-lite')
    implementation project(':animated-webp')
    implementation project(':static-webp')
    implementation project(':native-filters')
    implementation project(':native-imagetranscoder')

    implementation project(':drawee-backends:drawee-pipeline')
    implementation project(':drawee-span')
    implementation project(':imagepipeline-backends:imagepipeline-okhttp3')
    implementation project(':middleware')
    implementation project(':tools:flipper-fresco-plugin')
    implementation project(':tools:stetho')

    implementation 'com.facebook.keyframes:keyframes:1.0'

    implementation project(':ui-common')
    implementation project(':urimod')

    // Litho
    compileOnly Deps.Litho.lithoAnnotations
    implementation Deps.Litho.core
    implementation Deps.Litho.widget

    // Litho Sections
    implementation Deps.Litho.Sections.core
    implementation Deps.Litho.Sections.widget
    compileOnly Deps.Litho.Sections.sectionsAnnotations
    kapt Deps.Litho.Sections.processor

    // Experimental Fresco Vito
    implementation project(':vito:core')
    implementation project(':vito:core-common-impl')
    implementation project(':vito:core-impl')
    implementation project(':vito:core-java-impl')
    implementation project(':vito:drawee-support')
    implementation project(':vito:init')
    implementation project(':vito:ktx')
    implementation project(':vito:litho')
    implementation project(':vito:litho-slideshow')
    implementation project(':vito:options')
    implementation project(':vito:provider')
    implementation project(':vito:renderer')
    implementation project(':vito:source')
    implementation project(':vito:textspan')
    implementation project(':vito:tools:liveeditor')
    implementation project(':vito:view')

    // Only used for the custom SVG decoder
    implementation SampleDeps.Showcase.caverockSvg

    // Testing-only dependencies
    androidTestImplementation TestDeps.AndroidX.espressoCore
    androidTestImplementation TestDeps.AndroidX.testRules
    androidTestImplementation TestDeps.AndroidX.testRunner
    androidTestImplementation TestDeps.junit

    implementation(Deps.Tools.Flipper.flipper)

    implementation project(':tools:flipper')
    implementation Deps.SoLoader.soloader

    implementation Deps.Kotlin.stdlibJdk

    implementation SampleDeps.AndroidX.multidex
}
