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()
        //noinspection ExpiredTargetSdkVersion
        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@"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            zipAlignEnabled true
        }
    }
    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.viewpager2:viewpager2:1.0.0'
    implementation 'androidx.fragment:fragment-ktx:1.3.6'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.sprylab.xar:xar:0.9.9'
    implementation 'org.apache.commons:commons-compress:1.20'
    implementation 'commons-io:commons-io:2.8.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
