apply plugin: 'com.android.application'

/*
configurations.all {
    // Check latest snapshot on every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
*/

dependencies {
    implementation project(':vtm-android')
    implementation project(':vtm-android-mvt')
    implementation project(':vtm-extras')
    implementation project(':vtm-http')
    implementation project(':vtm-jeo')
    implementation project(':vtm-json')
    implementation project(':vtm-jts')
    implementation project(':vtm-mvt')
    implementation project(':vtm-themes')
    implementation "org.slf4j:slf4j-android:$slf4jVersion"

    implementation project(':vtm-android-gdx')
    implementation project(':vtm-gdx')
    implementation project(':vtm-gdx-poi3d')

    implementation 'org.mapsforge:mapsforge-poi-android:master-SNAPSHOT'
    implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-armeabi-v7a'
    implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-arm64-v8a'
    implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-x86'
    implementation 'org.mapsforge:sqlite-android:master-SNAPSHOT:natives-x86_64'
}

android {
    compileSdkVersion androidCompileSdk()
    buildToolsVersion "$androidBuildVersionTools"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    defaultConfig {
        versionCode project.versionCode()
        versionName project.versionName()
        minSdkVersion androidMinSdk()
        targetSdkVersion androidTargetSdk()
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            file("${rootDir}/vtm-android/natives").eachDir() { dir ->
                jniLibs.srcDirs += "${dir.path}/lib"
            }
            file("${rootDir}/vtm-android-gdx/natives").eachDir() { dir ->
                jniLibs.srcDirs += "${dir.path}/lib"
            }
        }
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    lintOptions { abortOnError false }

    packagingOptions {
        exclude 'META-INF/services/org.jeo.data.Driver'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    /*buildTypes {
        all {
            minifyEnabled true
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }*/
}

task run(dependsOn: 'installDebug') {
    doFirst {
        println(">> adb run...")
        String adb = System.getenv()['ANDROID_HOME'] + '/platform-tools/adb'
        String cmd = "${adb} shell am start -n org.oscim.android.test/.Samples"
        def proc = cmd.execute()
        proc.in.eachLine { line -> println line }
        proc.err.eachLine { line -> System.err.println('ERROR: ' + line) }
        proc.waitFor()
    }
}
