buildscript {
  ext.getExtOrDefault = {name ->
    return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['TrackPlayer_' + name]
  }

  repositories {
    google()
    mavenCentral()
  }

  dependencies {
    classpath "com.android.tools.build:gradle:8.7.2"
    // noinspection DifferentKotlinGradleVersion
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
  }
}


apply plugin: "com.android.library"
apply plugin: "kotlin-android"

apply plugin: "com.facebook.react"

def getExtOrIntegerDefault(name) {
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["TrackPlayer_" + name]).toInteger()
}

android {
  namespace "com.doublesymmetry.trackplayer"

  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

  defaultConfig {
    minSdkVersion getExtOrIntegerDefault("minSdkVersion")
    targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
  }

  buildFeatures {
    buildConfig true
  }

  buildTypes {
    release {
      minifyEnabled false
    }
  }

  lintOptions {
    disable "GradleCompatible"
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  sourceSets {
    main {
      java.srcDirs += [
        "generated/java",
        "generated/jni"
      ]
    }
  }
}

repositories {
  mavenCentral()
  google()
}

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
  implementation "com.facebook.react:react-android"
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

  // Make sure we're using androidx
  implementation "androidx.core:core-ktx:1.13.1"
  implementation "androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"
  implementation "androidx.lifecycle:lifecycle-process:2.8.6"
  implementation 'androidx.media:media:1.7.0'

  implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6")
  implementation("androidx.activity:activity-compose:1.9.3")
  implementation("androidx.compose.ui:ui")
  implementation("androidx.compose.ui:ui-graphics")

  implementation("androidx.media3:media3-exoplayer:1.8.0")
  implementation("androidx.media3:media3-session:1.8.0")
  implementation("androidx.media3:media3-ui:1.8.0")
  implementation("androidx.media3:media3-exoplayer-hls:1.8.0")
  implementation("androidx.media3:media3-exoplayer-dash:1.8.0")
  implementation("androidx.media3:media3-exoplayer-smoothstreaming:1.8.0")
  implementation("androidx.media3:media3-common:1.8.0")

  implementation "com.google.guava:guava:33.0.0-android"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.8.0"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"

  implementation 'io.coil-kt:coil:2.4.0'
  api 'com.jakewharton.timber:timber:5.0.1'

  implementation 'androidx.test:rules:1.6.1'
  implementation 'jp.wasabeef.transformers:coil:1.0.6'
}

react {
  jsRootDir = file("../src/")
  libraryName = "TrackPlayer"
  codegenJavaPackageName = "com.doublesymmetry.trackplayer"
}
