if (this.name == 'app') {
    apply plugin: 'com.android.application'
} else {
    apply plugin: 'com.android.library'
}
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlinx-serialization'
apply plugin: 'org.jetbrains.kotlin.plugin.compose'

android {
    compileSdk 36

    def localProperties = new Properties()
    def localPropertiesFile = rootProject.file("local.properties")
    if (localPropertiesFile.exists()) {
        localProperties.load(new FileInputStream(localPropertiesFile))
    }
    def googleServerClientId = localProperties.getProperty("serverClientId") ?: ""

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 36

        if (this.name == 'app') {
            applicationId "com.zigis.paleontologas"
            versionName "3.5.0"
            versionCode 37
        } else {
            consumerProguardFiles "consumer-rules.pro"
        }

        buildConfigField "String", "GOOGLE_SERVER_CLIENT_ID", "\"${googleServerClientId}\""

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            if (this.name == 'app') {
                shrinkResources false
                minifyEnabled true
            }
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        compose = true
        buildConfig = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_21
        targetCompatibility JavaVersion.VERSION_21
    }
}