// The Android Gradle Plugin builds the native code with the Android NDK.

group = 'com.github.dart_lang.jni'
version = '1.0'

buildscript {
    repositories {
        google()
        mavenCentral()
    }
}

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

apply plugin: 'com.android.library'

android {
    // Keeping the classes from being removed by proguard.
    defaultConfig {
        consumerProguardFiles 'consumer-rules.pro'
    }
    buildTypes {
        release {
            minifyEnabled = false
        }
    }

    // Condition for namespace compatibility in AGP 8
    if (project.android.hasProperty("namespace")) {
        namespace = 'com.github.dart_lang.jni'
    }

    // Adding [PortContinuation] and [PortProxy] classes shared between Flutter and
    // Dart-standalone versions of package:jni.
    sourceSets {
        main {
            java {
                srcDirs '../java/src/main/java'
            }
        }
    }

    // Bumping the plugin compileSdk requires all clients of this plugin
    // to bump the version in their app.
    compileSdk = 35

    ndkVersion = flutter.ndkVersion

    // Invoke the shared CMake build with the Android Gradle Plugin.
    externalNativeBuild {
        cmake {
            path = "../src/CMakeLists.txt"

            // The default CMake version for the Android Gradle Plugin is 3.10.2.
            // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
            //
            // The Flutter tooling requires that developers have CMake 3.10 or later
            // installed. You should not increase this version, as doing so will cause
            // the plugin to fail to compile for some customers of the plugin.
            // version "3.10.2"
        }
    }

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

    defaultConfig {
        minSdk = 21
    }
}
