plugins {
    id 'com.android.application'
    id 'com.google.android.gms.oss-licenses-plugin'
}

repositories {
    mavenCentral()
    maven {
        url 'https://jitpack.io'
    }
}

android {
    compileSdk 36

    packagingOptions {
        resources {
            excludes += ['META-INF/DEPENDENCIES', 'mozilla/public-suffix-list.txt', 'META-INF/LICENSE', 'META-INF/LICENSE.md', 'META-INF/NOTICE.md','META-INF/LICENSE.txt', 'META-INF/license.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt', 'META-INF/notice.txt', 'META-INF/ASL2.0', 'META-INF/*.kotlin_module']
        }
    }

    defaultConfig {
        applicationId "com.astarivi.kaizoyu"
        minSdkVersion 23
        targetSdkVersion 36
        versionCode 12
        versionName "1.1"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    buildTypes {
        debug {
            applicationIdSuffix '.debug'
            versionNameSuffix '-DEBUG'
            resValue "string", "app_k_name", "Kaizoyu! Debug"
        }

        beta {
            applicationIdSuffix '.beta'
            versionNameSuffix '01-BETA'
            resValue "string", "app_k_name", "Kaizoyu! Beta"
        }

        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            resValue "string", "app_k_name", "Kaizoyu!"
        }
    }

    flavorDimensions "release"

    productFlavors {
        mainline {
            applicationId "com.astarivi.kaizoyu"
            dimension "release"
            getIsDefault().set true

            resValue "string", "is_fdroid", "false"
        }

        fdroid {
            applicationId "ovh.kaizoyu.app"
            dimension "release"

            resValue "string", "is_fdroid", "true"
        }
    }

    applicationVariants.configureEach { variant ->
        resValue "string", "provider_authority", variant.applicationId + ".fileprovider"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
        coreLibraryDesugaringEnabled true
    }

    buildFeatures {
        viewBinding true
    }

    namespace 'com.astarivi.kaizoyu'

    splits {
        abi {
            enable true
            reset()

            include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
            universalApk true
        }
    }
}

dependencies {
    // Core library
    implementation project(':service')

    // External libraries (third party)
    // Guava solves a dependency issue between ACRA.ch and work-runtime
    implementation 'com.google.guava:guava:33.4.8-android'
    implementation 'com.github.WrichikBasu:AudioFocusController:3.0.2'
    implementation 'com.google.android.gms:play-services-oss-licenses:17.1.0'
    implementation 'com.github.astarivi:Zparc:1.1'

    //noinspection NewerVersionAvailable,GradleDependency
    implementation ('org.videolan.android:libvlc-all:4.0.0-eap11') {
        because 'EAP12 HWA chroma blending is broken (RGBA -> ANOP). Subtitles will not work'
    }

    implementation 'com.airbnb.android:lottie:6.6.6'
    implementation 'com.github.bumptech.glide:glide:4.16.0'
    implementation 'com.github.bumptech.glide:recyclerview-integration:4.16.0'
    implementation 'com.github.bumptech.glide:okhttp3-integration:4.16.0'
    implementation 'org.jetbrains:annotations:26.0.2'
    implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:12.1.1'
    implementation 'com.rometools:rome:2.1.0'

    // Lombok
    //noinspection AnnotationProcessorOnCompilePath
    compileOnly 'org.projectlombok:lombok:1.18.38'
    annotationProcessor 'org.projectlombok:lombok:1.18.38'
    //noinspection AnnotationProcessorOnCompilePath
    testCompileOnly 'org.projectlombok:lombok:1.18.38'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.38'

    // Analytics
    implementation 'ch.acra:acra-http:5.12.0'
    // Ads
    implementation 'com.startapp:inapp-sdk:5.2.0'

    // Android X
    implementation 'androidx.paging:paging-runtime:3.3.6'
    implementation 'androidx.paging:paging-guava:3.3.6'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-beta01'
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
    implementation 'androidx.work:work-runtime:2.10.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel:2.9.0'
    implementation 'androidx.lifecycle:lifecycle-livedata:2.9.0'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.room:room-runtime:2.7.1'
    implementation 'androidx.room:room-paging:2.7.1'
    annotationProcessor 'androidx.room:room-compiler:2.7.1'

    // Logger
    implementation 'org.tinylog:tinylog-api:2.7.0'
    implementation 'org.tinylog:tinylog-impl:2.7.0'
    runtimeOnly 'org.tinylog:slf4j-tinylog:2.7.0'

    // Jackson
    // Don't update to 2.14 as Android minSdk support changes.
    //noinspection GradleDependency
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.5'
    //noinspection GradleDependency
    implementation 'com.fasterxml.jackson.core:jackson-core:2.13.5'
    //noinspection GradleDependency
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.5'

    // HTTP
    implementation 'com.squareup.okhttp3:okhttp:4.12.0'

    // Google others
    implementation 'com.google.android.material:material:1.12.0'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'

    // Testing? What's that
}
