plugins {
    id 'com.android.library'
    id 'androidx.benchmark'
    id 'org.jetbrains.kotlin.android'
}

allprojects {
    repositories {
        mavenLocal()
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

android {
    namespace 'com.alibaba.gaiax.benchmark'
    compileSdk 33

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

    kotlinOptions {
        jvmTarget = "1.8"
    }

    defaultConfig {
        minSdk 24
        targetSdk 33

        testInstrumentationRunner 'androidx.benchmark.junit4.AndroidBenchmarkRunner'
        // https://developer.android.google.cn/topic/performance/benchmarking/microbenchmark-profile?hl=zh-cn#method-tracing
        // must be one of: 'None', 'StackSampling', or 'MethodTracing'
        testInstrumentationRunnerArguments["androidx.benchmark.profiling.mode"] = "StackSampling"
        testInstrumentationRunnerArguments["androidx.benchmark.profiling.sampleDurationSeconds"] = "10"
    }

    sourceSets {
        main {
            java.srcDirs = ['src/main/kotlin', 'src/main/java']
            jniLibs.srcDir 'src/main/jniLibs'
        }

        // https://stackoverflow.com/questions/26244998/androidmanifest-in-androidtest-directory-being-ignored/27884436#27884436
        // https://stackoverflow.com/questions/26663539/configuring-res-srcdirs-for-androidtest-sourceset
        // https://stackoverflow.com/questions/23643189/android-gradle-src-androidtest-res-layout-mylayout-xml-not-found-in-mypackage-r
        androidTest {
            java.srcDirs = ['src/androidTest/java']
            res.srcDirs = ['src/androidTest/res']
            jniLibs.srcDir 'src/androidTest/jniLibs'
            manifest.srcFile "src/androidTest/AndroidManifest.xml"
        }
    }

    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }

    testBuildType = "release"
    buildTypes {
        debug {
            // Since debuggable can"t be modified by gradle for library modules,
            // it must be done in a manifest - see src/androidTest/AndroidManifest.xml
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "benchmark-proguard-rules.pro"
        }
        release {
            isDefault = true
        }
    }
}

dependencies {
    androidTestImplementation 'androidx.test:runner:1.5.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.benchmark:benchmark-junit4:1.1.1'
    androidTestImplementation 'androidx.recyclerview:recyclerview:1.0.0'
    androidTestImplementation "androidx.appcompat:appcompat:1.0.0"

    // Add your dependencies here. Note that you cannot benchmark code
    // in an app module this way - you will need to move any code you
    // want to benchmark to a library module:
    // https://developer.android.com/studio/projects/android-library#Convert

    androidTestImplementation project(path: ':GaiaXAndroidAdapter')
    androidTestImplementation project(path: ':GaiaXAndroid')
    androidTestImplementation 'com.github.bumptech.glide:glide:4.12.0'
    androidTestImplementation 'com.alibaba:fastjson:1.2.76'
    androidTestImplementation 'com.airbnb.android:lottie:4.1.0'

}