buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        //noinspection AndroidGradlePluginVersion
        classpath 'com.android.tools.build:gradle:9.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.0"
    }
}

repositories {
    google()
    mavenCentral()
}

apply plugin: qtGradlePluginType

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    //noinspection GradleDependency
    implementation 'androidx.core:core:1.17.0'
}

android {
    /*******************************************************
     * The following variables:
     * - androidBuildToolsVersion,
     * - androidCompileSdkVersion
     * - qtAndroidDir - holds the path to qt android files
     *                   needed to build any Qt application
     *                   on Android.
     * - qtGradlePluginType - whether to build an app or a library
     *
     * are defined in gradle.properties file. This file is
     * updated by QtCreator and androiddeployqt tools.
     * Changing them manually might break the compilation!
     *******************************************************/

    namespace = androidPackageName
    compileSdkVersion androidCompileSdkVersion
    buildToolsVersion androidBuildToolsVersion
    ndkVersion = androidNdkVersion

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = [qtAndroidDir + '/src', 'src', 'java']
            kotlin.srcDirs = [qtAndroidDir + '/src', 'src', 'kotlin']
            aidl.srcDirs = [qtAndroidDir + '/src', 'src', 'aidl']
            res.srcDirs = [qtAndroidDir + '/res', 'res']
            resources.srcDirs = ['resources']
            renderscript.srcDirs = ['src']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
       }
    }

    tasks.withType(JavaCompile) {
        options.incremental = true
        options.compilerArgs += ['-Xlint:all']
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    lintOptions {
        abortOnError = false
    }

    aaptOptions {
        // Do not compress Qt binary resources file
        noCompress 'rcc'
    }

    packagingOptions {
        jniLibs {
            useLegacyPackaging = legacyPackaging
        }
    }

    defaultConfig {
        resConfig "en"
        minSdkVersion qtMinSdkVersion
        targetSdkVersion qtTargetSdkVersion
        ndk.abiFilters = qtTargetAbiList.split(",")
    }
}
