group 'io.agora.agora_rtc_ng'
version '1.0-SNAPSHOT'

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

buildscript {
    repositories {
        google()
        mavenCentral()
    }

}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

apply plugin: 'com.android.library'

android {
    // Conditional for compatibility with AGP <4.2.
    if (project.android.hasProperty("namespace")) {
        namespace 'io.agora.agora_rtc_ng'
    }
    compileSdkVersion safeExtGet('compileSdkVersion', 31)

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 21)

        consumerProguardFiles 'consumer-rules.pro'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
        if (isDev(project)) {
           main.jniLibs.srcDirs += 'libs'
        }
    }

    externalNativeBuild {
        cmake {
            path 'src/main/cpp/CMakeLists.txt'
        }
    }
}

dependencies {
  if (isDev(project)) {
    api fileTree(dir: "libs", include: ["*.jar"])
  } else {
    // iris dependencies start
    api 'io.agora.rtc:iris-rtc:4.5.2-build.1'
    // iris dependencies end

    // native dependencies start
    api 'io.agora.rtc:full-sdk:4.5.2'
    api 'io.agora.rtc:full-screen-sharing:4.5.2'
    // native dependencies end
  }
}

static boolean isDev(Project project) {
  def devFile = project.file('.plugin_dev')
  return devFile.exists()
}