// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        google()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.13.2'
        classpath 'com.google.gms:google-services:4.5.0'
//        classpath 'com.huawei.agconnect:agcp:1.9.1.301'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.8'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0"

        //noinspection GradleDependency
        classpath "io.sentry:sentry-android-gradle-plugin:6.26.0"
        // db
        classpath "io.objectbox:objectbox-gradle-plugin:5.4.2"
        // json
        classpath "org.jetbrains.kotlin:kotlin-serialization:2.1.0"
    }
}

// Strip JLatexMath fonts we don't ship (transitive AAR assets from
// io.noties.markwon:ext-latex -> ru.noties:jlatexmath-android, ~764 KB total under
// assets/org/scilab/forge/jlatexmath/fonts/). Has to live in the APK modules — a
// library's androidResources.ignoreAssetsPattern doesn't filter packaging in apps
// that consume it. Using subprojects keeps it in one place.
//   keep:  base/, latin/, maths/, euler/  (\mathbb, \mathcal, \mathfrak still work)
//   drop:  latin/optional/, maths/optional/  (~290 KB; \textbf/\textit/\mathds fall back)
//          licences/                          (~20 KB; pure license text files)
subprojects {
    plugins.withId('com.android.application') {
        android {
            androidResources {
                ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~:!optional:!licences:!*stmary*:!*eufb*'
            }
        }
    }

    if (project.projectDir.absolutePath.contains('/TMessagesProj_Modules/media/')) {
        project.plugins.withId('com.android.library') {
            project.android {
                if (namespace == null) {
                    def manifestFile = file("${project.projectDir}/src/main/AndroidManifest.xml")

                    if (manifestFile.exists()) {
                        def manifest = new XmlSlurper().parse(manifestFile)
                        def manifestPackage = manifest.@package.text()

                        if (manifestPackage) {
                            namespace manifestPackage
                        }
                    }
                }
            }
        }
    }
}

ext {
    ndkVersion = "27.2.12479018"
}

allprojects {
    repositories {
        // The order in which you list these repositories matter.
        mavenCentral()
        google()
    }
}