apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
//apply plugin: 'com.github.dcendents.android-maven'
//group = 'com.github.albert-lii'

def comiple_sdk_version = 25
def build_tool_version = "25.0.3"
def support_version = "25.3.1"
def min_sdk_version = 9
def target_sdk_version = 22
def version_code = 23
def version_name = "2.0.7"

def bintrayName = "albertlii"
def bintrayRepoName = "android-maven"
def bintrayGroupId = "com.liyi.sutils"
def bintrayArtifactId = "sutils"
def bintrayDesc = "sutils"
def bintrayWebSite = "https://github.com/albert-lii/SUtils"
def bintrayLicences = ['Apache-2.0']

android {
    compileSdkVersion comiple_sdk_version
    buildToolsVersion build_tool_version

    defaultConfig {
        minSdkVersion min_sdk_version
        targetSdkVersion target_sdk_version
        versionCode version_code
        versionName version_name

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:' + support_version
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation files('libs/core-3.2.1.jar')
}

publish {
    // bintray 用户名
    userOrg = bintrayName
    // 要传到的 maven 的名字。你可能有多个 maven，要传哪个写哪个。
    repoName = bintrayRepoName
    // jcenter 上的路径
    groupId = bintrayGroupId
    // 项目名称
    artifactId = bintrayArtifactId
    // 版本号
    publishVersion = version_name
    // 描述，不重要
    desc = bintrayDesc
    // 网站，不重要；尽量模拟 github 上的地址
    website = bintrayWebSite
    licences = bintrayLicences
}

// 指定编码
tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}

// 打包源码
task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    failOnError false
    source = android.sourceSets.main.java.sourceFiles
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    classpath += configurations.compile
}

// 制作文档(Javadoc)
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}
