buildscript {
    ext {
        kotlinVersion = '2.3.0'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()

        // // Zoho SalesIQ Mobilisten
        // maven {
        //     url 'https://maven.zohodl.com'
        // }

        maven {
            url  "https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android"
        }
    }
}

rootProject.buildDir = '../build'

subprojects {
    afterEvaluate { project ->
        if (project.extensions.findByName("android") != null) {
            // Ref: https://github.com/flutter/flutter/issues/153281#issuecomment-2292201697
            Integer pluginCompileSdk = project.android.compileSdk
            if (pluginCompileSdk != null && pluginCompileSdk < 34) {
                // project.logger.warning(
                //         "Warning: Overriding compileSdk version in Flutter plugin: "
                //                 + project.name
                //                 + " from "
                //                 + pluginCompileSdk
                //                 + " to 34 (to work around https://issuetracker.google.com/issues/199180389)."
                // )
                project.android {
                    compileSdk 34
                }
            }

            if (project.plugins.hasPlugin('kotlin-android')) {
                // project.logger.error(
                //         "Warning: upgrade Java version to VERSION_11 in Flutter plugin: "
                //                 + project.name
                // )
                project.android {
                    kotlinOptions {
                        jvmTarget = "11"
                    }
                    compileOptions {
                        sourceCompatibility = JavaVersion.VERSION_11
                        targetCompatibility = JavaVersion.VERSION_11
                    }
                }
            }
        }
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    // project.logger.error(
                    //         "Warning: Adding missing namespace ("
                    //                 + project.group + ") in Flutter plugin: "
                    //                 + project.name
                    //                 + " (to work around the error occurs after Android Gradle Plugin updated >= 8.x.x.)."
                    // )
                    namespace project.group
                }
            }
        }
    }
}

subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register('clean', Delete) {
    delete rootProject.layout.buildDirectory
}
