plugins {
  id("com.android.library")
  id("org.jetbrains.kotlin.android")
  id("com.vanniktech.maven.publish")
}

dependencies {
  api projects.sharkAndroid
  api projects.leakcanaryObjectWatcherAndroidCore
  api projects.leakcanaryObjectWatcherAndroidAndroidx
  api projects.leakcanaryObjectWatcherAndroidSupportFragments
  implementation libs.kotlin.stdlib

  // Optional dependency
  compileOnly libs.androidX.work.runtime
  compileOnly libs.androidX.work.multiprocess

  testImplementation libs.assertjCore
  testImplementation libs.junit
  testImplementation libs.kotlin.reflect
  testImplementation libs.mockito
  testImplementation libs.mockitoKotlin
  androidTestImplementation libs.androidX.test.espresso
  androidTestImplementation libs.androidX.test.rules
  androidTestImplementation libs.androidX.test.runner
  androidTestImplementation libs.assertjCore
  androidTestImplementation projects.sharkHprofTest
  androidTestUtil libs.androidX.test.orchestrator
}

def gitSha() {
  return 'git rev-parse --short HEAD'.execute().text.trim()
}

android {
  resourcePrefix 'leak_canary_'
  compileSdk versions.compileSdk
  defaultConfig {
    minSdk versions.minSdk
    // Avoid DeprecatedTargetSdkVersionDialog during UI tests
    targetSdk versions.compileSdk
    buildConfigField "String", "LIBRARY_VERSION", "\"${rootProject.ext.VERSION_NAME}\""
    buildConfigField "String", "GIT_SHA", "\"${gitSha()}\""
    consumerProguardFiles 'consumer-proguard-rules.pro'
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    testInstrumentationRunnerArguments clearPackageData: 'true'
    testOptions {
      execution 'ANDROIDX_TEST_ORCHESTRATOR'
    }
  }
  lintOptions {
    disable 'GoogleAppIndexingWarning'
    error 'ObsoleteSdkInt'
    checkOnly 'Interoperability'
  }
}
