plugins {
    id('com.android.application')
}

def getGitCommitId() {
    ("git -C " + project.getProperty('EXULT_SOURCE_DIR') + " rev-parse --verify --short HEAD").execute().text.trim()
}

android {
    compileSdkVersion @ANDROID_SDK_VERSION@
    buildToolsVersion "@ANDROID_BUILD_TOOLS_VERSION@"
    ndkVersion "@ANDROID_NDK_VERSION@"

    defaultConfig {
        applicationId "info.exult"
        namespace 'info.exult'
        minSdkVersion 28 // could lower to 18 if we locally implement glob()
        targetSdkVersion @ANDROID_SDK_VERSION@
        versionCode 1
        versionName "@VERSION@ (" + getGitCommitId() + ")"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++17"
                arguments "-DANDROID_STL=c++_shared", "-DEXULT_SOURCE_DIR=" + project.getProperty('EXULT_SOURCE_DIR'), "-DSDL_SOURCE_DIR=" + project.getProperty('SDL_SOURCE_DIR'), "-DEXULT_VERSION=@PACKAGE_VERSION@"
            }
        }
        ndk {
            @ANDROID_ARCHITECTURE@
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            zipAlignEnabled true
        }
        debug {
            externalNativeBuild {
                cmake {
                    arguments.add("-DEXULT_ANDROID_DEBUG=@EXULT_ANDROID_DEBUG@")
                    arguments.add("-DEXULT_ANDROID_OPT=@EXULT_ANDROID_OPT@")
                }
            }
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "@ANDROID_CMAKE_VERSION@"
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.core:core:1.13.1'
    implementation 'androidx.activity:activity:1.9.3'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'androidx.fragment:fragment-ktx:1.8.5'
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
    implementation 'com.sprylab.xar:xar:0.9.11'
    implementation 'org.apache.commons:commons-compress:1.27.1'
    implementation 'commons-io:commons-io:2.18.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}
