apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

/*model {*/
  /*  repositories {
        libs(PrebuiltLibraries) {
            SDL2 {
                headers.srcDir "../SDL2/include"
                binaries.withType(SharedLibraryBinary) {
                    sharedLibraryFile = file("${gradle.libDistributionRoot}/SDL2/lib/${targetPlatform.getName()}/libSDL2.so")
                }
            }
            main {
                binaries.withType(SharedLibraryBinary) {
                    sharedLibraryFile = file("${gradle.libDistributionRoot}/main/lib/${targetPlatform.getName()}/libmain.so")
                }
            }
        }
    }
*/
    android {
        compileSdkVersion = gradle.sdkVersion

        defaultConfig {
            applicationId = 'rocks.georgik.sdlapp'
            minSdkVersion gradle.minSdkVersion
            targetSdkVersion gradle.targetSdkVersion
        }
       /* sources {
            main {
                jni {
                    dependencies {
                        project ':main' linkage 'shared'
                    }   
                }   
                jniLibs {
                    source {
                        srcDir "${gradle.libDistributionRoot}/main/lib"
                    }   
                }   
            }
        }   */
        productFlavors {
            flavorDimensions 'abi'
            
            arm {
                ndk {
                    abiFilter 'armeabi-v7a'
                }
            }
            arm64 {
                ndk {
                    abiFilter 'arm64-v8a'
                }
            }
            x86 {
                ndk {
                    abiFilter 'x86'
                }
            }
            x86_64 {
                ndk {
                    abiFilter 'x86_64'
                }
            }
            all_in_one {
                ndk {
                    //abiFilter 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
                }
            }
        }
        signingConfigs {
            release {
                storeFile file("keystore-path")
                storePassword "keystore-pass"
                keyAlias "alias"
                keyPassword "alias-password"

                // Optional, specify signing versions used
                v1SigningEnabled true
                v2SigningEnabled true
            }
        }
        buildTypes {
            release {
                minifyEnabled = false
                proguardFiles.add(file('proguard-rules.txt'))
                // Uncomment to enable apk signing (and also fill details in signingConfigs Block)
                //signingConfig signingConfigs.release
            }
        }
        externalNativeBuild {
            cmake {
                path "../main/CMakeLists.txt"
                //path "../SDL2/CMakeLists.txt"
                version "3.10.2"
            }
        }
    }
/*}*/

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:+'
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
/*
tasks.whenTaskAdded { task ->
    if (task.name.contains('compile')) {
        task.dependsOn ':main:distributeLib'
    }
}*/
