plugins {
    id("com.android.test")
    id("org.jetbrains.kotlin.android")
    id("androidx.baselineprofile")
}

android {
    namespace = "com.ponzischeme89.memby.benchmark"
    compileSdk = 35

    defaultConfig {
        // Baseline profile generation needs API 28+. The app itself still ships to 23 —
        // this floor applies only to the machine generating the profile, not to the TVs
        // that consume it.
        minSdk = 28
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        // No DEBUGGABLE suppression any more: the baselineprofile plugin adds
        // nonMinifiedRelease / benchmarkRelease variants to :app and mirrors them here,
        // so these are real release numbers rather than the debug-influenced ones the
        // Phase 1 setup produced.
        testInstrumentationRunnerArguments["androidx.benchmark.enabledRules"] = "Macrobenchmark,BaselineProfile"
    }
    targetProjectPath = ":app"
    experimentalProperties["android.experimental.self-instrumenting"] = true

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

    buildTypes {
        create("release") {
            initWith(getByName("debug"))
            isDebuggable = false
        }
    }
}

baselineProfile {
    // A television is the only device that produces a representative profile for this
    // app, so generation always runs against whatever is connected over adb.
    useConnectedDevices = true
}

kotlin {
    compilerOptions {
        jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
    }
}

dependencies {
    implementation("androidx.benchmark:benchmark-macro-junit4:1.3.4")
    implementation("androidx.test.ext:junit:1.2.1")
    implementation("androidx.test:runner:1.6.2")
    implementation("androidx.test.uiautomator:uiautomator:2.3.0")
}
