buildscript{
    repositories{
        google()
        mavenLocal()
        mavenCentral()
    }
    dependencies{
        classpath 'com.android.tools.build:gradle:4.2.0'
    }
}

repositories{
    google()
    mavenLocal()
    mavenCentral()
}

apply plugin: 'com.android.application'

android{
    compileSdkVersion 30
    ndkVersion "21.3.6528147"

    sourceSets{
        main{
            manifest.srcFile 'AndroidManifest.xml'
            assets.srcDirs = ['../assets/']
            res.srcDirs = ['res']
        }
    }

    defaultConfig{
        applicationId 'io.anuke.animdustry'
        versionName "testing"
        versionCode 3

        minSdkVersion 14
        targetSdkVersion 30
    }
    
    signingConfigs{
        release{
            storeFile System.getenv("ANIMDUSTRY_KEYSTORE_PATH") == null ? new File("no") : new File((String)System.getenv("ANIMDUSTRY_KEYSTORE_PATH"))
            storePassword System.getenv("ANIMDUSTRY_KEYSTORE_PASS")
            keyAlias "anuke"
            keyPassword System.getenv("ANIMDUSTRY_KEYSTORE_PASS")
        }
    }
    
    buildTypes{
	    release{
	        signingConfig signingConfigs.release
	    }
	}

    externalNativeBuild{
        cmake{
            version '3.10.2'
            path 'src/CMakeLists.txt'
        }
    }
}

task run(type: Exec){
    commandLine "${android.getSdkDirectory().getAbsolutePath()}/platform-tools/adb", 'shell', 'am', 'start', '-n', 'io.anuke.animdustry/android.app.NativeActivity'
}

tasks.whenTaskAdded{ task ->
    if(task.name == 'installDebug'){
        run.dependsOn task
    }
}
