apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    def version = System.getenv("APP_VERSION_NAME") ?: "1.0.0"
    def parts = version.split('\\.')
    def major = parts[0]
    def minor = parts[1]
    def patch = parts[2]

    if (major.size() == 1) major = major + "0"
    if (minor.size() == 1) minor = minor + "0"
    if (patch.size() == 1) patch = patch + "0"

    def code = (major + minor + patch) as Integer

    defaultConfig {
        applicationId "net.strct.kalker"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode code
        versionName version
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    flatDir{
        dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    implementation project(':capacitor-android')
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
    testImplementation "junit:junit:$junitVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
    implementation project(':capacitor-cordova-android-plugins')
}

apply from: 'capacitor.build.gradle'