
pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()


    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    // Get vital-sign-engine path
//    def vitalSignEngine =  {
//        def properties = new Properties()
//        file("local.properties").withInputStream { properties.load(it) }
//        def vitalSignEnginePath = properties.getProperty("vital.sign.engine.path")
//        assert vitalSignEnginePath != null, "vital.sign.engine.path not set in local.properties"
//        return vitalSignEnginePath
//    }()

    repositories {
        google()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
        gradlePluginPortal()
    }

    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "com.huawei.agconnect") {
                useModule("com.huawei.agconnect:agcp:1.9.1.304")
            }
        }
    }

    dependencyResolutionManagement {
        repositories {
            google()
            mavenCentral()
            gradlePluginPortal()
            flatDir {
                dirs 'libs'
            }
            maven {
                url 'https://developer.huawei.com/repo/'
            }
            maven {
                url "https://artifactory.ess-dev.com/artifactory/gradle-dev-local"
            }
            maven {
                url 'https://api.mapbox.com/downloads/v2/releases/maven'
                credentials {
                    username = 'mapbox'
                    password = "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg"
                    if (password == null || password == "") {
                        throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the environment variables.")
                    }
                }
                authentication {
                    basic(BasicAuthentication)
                }
            }
        }
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version '8.11.0' apply false
    id("org.jetbrains.kotlin.android") version "2.2.0" apply false
    id("com.google.gms.google-services") version "4.4.3" apply false
    id("com.google.firebase.crashlytics") version "3.0.4" apply false
    id('org.gradle.toolchains.foojay-resolver-convention') version '0.9.0' apply false
    id "com.huawei.agconnect" version "1.9.1.304" apply false


}

include ":app"

//// Add the following to include vitalSignEngine as a module
//def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
//def properties = new Properties()
//assert localPropertiesFile.exists()
//localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
//def vitalSignEnginePath = properties.getProperty('vital.sign.engine.path')
//assert vitalSignEnginePath != null : "vital.sign.engine.path not set in local.properties"
//
//include ':vitalSignEngine'
//project(':vitalSignEngine').projectDir = file(vitalSignEnginePath)
