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

android {
    compileSdkVersion 28


    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    api 'androidx.appcompat:appcompat:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    api "androidx.core:core-ktx:1.2.0-alpha04"
    api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    api 'com.afollestad.material-dialogs:core:3.1.0'
    api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
    api "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha04"
    api 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha04'
    api 'androidx.recyclerview:recyclerview:1.1.0-beta04'
}

repositories {
    mavenCentral()
}


if (project.hasProperty("kotlin")) {
    // Disable creating javadocs
    tasks.withType(Javadoc) {
        enabled = false
    }
}

//生成源文件
task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

//生成Javadoc文档
task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

//文档打包成jar
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

//拷贝javadoc文件
task copyDoc(type: Copy) {
    from "${buildDir}/docs/"
    into "docs"
}

//上传到JCenter所需要的源码文件
artifacts {
    archives javadocJar
    archives sourcesJar
}

//解决 JavaDoc 中文注释生成失败的问题
tasks.withType(Javadoc) {
    options.addStringOption('Xdoclint:none', '-quiet')
    options.addStringOption('encoding', 'UTF-8')
    options.addStringOption('charSet', 'UTF-8')
}


//发布到 Bintray
publish {

    userOrg = 'luyaox'           //bintray.com 注册的用户名
    groupId = 'luyao.util.ktx'   //以后访问 jcenter上此项目的路径，一般和库项目的包名一致
    artifactId = 'AndroidUtilKTX'       //bintray.com 创建的 Package 名
    publishVersion = '0.0.7-alpha02'         //版本号
    desc = 'Android Kotlin Util Code' //版本说明，随意
    website = 'https://github.com/lulululbj/AndroidUtilCodeKTX'    //关于这个开源项目的网站，随意
}