/*
 * Copyright (c) 2018 Nam Nguyen, nam@ene.im
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
// apply plugin: 'com.getkeepsafe.dexcount'

if (file("google-services.json").exists()) {
  System.out.println("google-services.json found!")
  apply plugin: 'com.google.gms.google-services'
  apply plugin: 'com.google.firebase.crashlytics'
} else {
  System.out.println("google-services.json not found.")
}

android {
  namespace 'kohii.v1.sample'
  compileSdkVersion libs.versions.android.target.sdk.get().toInteger()

  signingConfigs {
    release {
      keyAlias kohii_prodKeyAlias
      keyPassword prodKeyPassword
      storeFile file(prodStoreFile)
      storePassword prodStorePassword
    }

    debug {
      keyAlias "debug"
      keyPassword "android"
      storeFile file("debug.jks")
      storePassword "android"
    }
  }

  defaultConfig {
    applicationId "kohii.v1.sample"
    minSdkVersion libs.versions.android.min.sdk.get()
    targetSdkVersion libs.versions.android.target.sdk.get()
    versionCode libs.versions.release.code.get().toInteger()
    versionName libs.versions.release.name.get()

    buildConfigField("String", "YT_API_KEY", "\"${kohii_yt_api_key}\"")

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    testApplicationId 'kohii.v1.sample.test'
  }

  buildTypes {

    release {
      signingConfig signingConfigs.release
      minifyEnabled true
      shrinkResources true
      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }

    debug {
      applicationIdSuffix ".dev"
      signingConfig signingConfigs.debug
      // multiDexEnabled true
      minifyEnabled false
      shrinkResources false
    }
  }
  packagingOptions {
    resources {
      excludes +=
          ['META-INF/services/javax.annotation.processing.Processor', 'META-INF/DEPENDENCIES']
    }
  }

  buildFeatures {
    viewBinding true
    dataBinding true
  }

  productFlavors {}
}

configurations {
  all {
    exclude module: 'httpclient'
  }
}

dependencies {
  implementation project(':kohii-core')
  implementation project(':kohii-exoplayer')
  implementation project(':kohii-androidx')
  implementation project(':kohii-experiments')
  implementation project(':kohii-ads')

  implementation(libs.android.exoplayer.all)
  implementation(libs.android.exoplayer.ima)
  implementation(libs.androidx.media2.widget)

  implementation(libs.androidx.core)
  implementation(libs.androidx.fragment)
  implementation(libs.androidx.appcompat)
  implementation(libs.androidx.recyclerview)
  implementation(libs.androidx.recyclerview.selection)
  implementation(libs.androidx.constraintlayout)
  implementation(libs.androidx.material)

  implementation(libs.androidx.lifecycle.process)
  implementation(libs.androidx.lifecycle.runtime)
  implementation(libs.androidx.lifecycle.viewmodel)
  implementation(libs.androidx.lifecycle.livedata)
  implementation(libs.androidx.lifecycle.java8)

  implementation(libs.androidx.paging.common)
  implementation(libs.androidx.paging.runtime)

  implementation(libs.androidx.viewpager2)

  implementation(libs.square.moshi)
  kapt(libs.square.moshi.codegen)
  implementation(libs.okio)

  implementation(libs.glide)
  kapt(libs.compiler)
  implementation(libs.androidsvg.aar)

  implementation(libs.firebase.crashlytics.ktx) {
    transitive = true
  }

  implementation(libs.google.api.services.youtube)
  implementation(libs.google.http.client.android)
  implementation(libs.google.api.client.android)
  implementation(libs.google.api.client.gson)
  implementation(libs.firebase.analytics)

  implementation(libs.timber)

  implementation(libs.square.leakcanary.plumber)
  debugImplementation(libs.square.leakcanary)

  testImplementation(libs.androidx.core.ktx)
  testImplementation(libs.androidx.rules)
  testImplementation(libs.androidx.runner)

  androidTestImplementation(libs.androidx.junit.ktx)
  androidTestImplementation(libs.androidx.espresso.core)
}
