buildscript {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    properties.keys().each { key -> project.ext.set(key, properties.getProperty(key))
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'

def trojan_version_code = 11
def trojan_version = "0.1.1"

android {
    //这是为了debug C++而加的，后面要去掉
    //publishNonDefault true

    compileSdkVersion 23
    buildToolsVersion '25.0.2'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode trojan_version_code
        versionName "$trojan_version"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -frtti -fexceptions"
            }
        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable true
            jniDebuggable true
        }
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'

    provided "com.squareup.retrofit2:converter-gson:2.0.1"
    provided "me.ele:lancet-base:1.0.2"
}

def outputPath = project.rootProject.buildDir.parentFile.getPath() + "/archives/${trojan_version}"
def module_name = "trojan"

task copyOutputs {
    doLast {
        copy {
            from project.rootProject.buildDir.parentFile.getPath() + "/${module_name}/build/outputs"
            into outputPath
        }
    }
}

publish {
    userOrg = 'michaelzhong'
    groupId = 'me.ele'
    artifactId = 'trojan-library'
    publishVersion = "$trojan_version"
}
