apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "28.0.3"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 10
        versionName "1.1.2"

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

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



ext {
    bintrayRepo = 'androidlibrary'
    bintrayName = 'Captcha'//在bintray网站中项目中填写的名称

    publishedGroupId = 'com.luozm.captcha'//一般为包名
    libraryName = 'captcha'//library名字需要和本地的lib module一致
    artifact = 'captcha'//同上

    libraryDescription = 'An Android captcha widget.'//项目描述
    libraryVersion = '1.1.2'//项目版本号,只需要在每次更新的时候填写

    siteUrl = 'https://github.com/luozhanming/Captcha'
    gitUrl = 'https://github.com/luozhanming/Captcha.git'

    developerId = 'luozm'//开发者Id
    developerName = 'Jam Luo'//开发者名称
    developerEmail = 'luozhanming123@gmail.com'//邮箱

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ['Apache-2.0']
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:25.3.1'
    testImplementation 'junit:junit:4.12'
}

apply plugin: 'com.github.dcendents.android-maven'
group = publishedGroupId
install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                groupId publishedGroupId
                artifactId artifact

                // Add your description here
                name libraryName
                description libraryDescription
                url siteUrl

                // Set your license
                licenses {
                    license {
                        name licenseName
                        url licenseUrl
                    }
                }
                developers {
                    developer {
                        id developerId
                        name developerName
                        email developerEmail
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl

                }
            }
        }
    }
}

apply plugin: 'com.jfrog.bintray'
version = libraryVersion

if (project.hasProperty("android")) { // Android libraries
    task sourcesJar(type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.srcDirs
    }

    task javadoc(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    }
} else { // Java libraries
    task sourcesJar(type: Jar, dependsOn: classes) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")

    configurations = ['archives']
    pkg {
        repo = bintrayRepo
        name = bintrayName
        desc = libraryDescription
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = allLicenses
        publish = true
        publicDownloadNumbers = true
        version {
            desc = libraryDescription
            gpg {
                // optional GPG encryption. Default is false.
                sign = false
                //passphrase = properties.getProperty("bintray.gpg.password")
            }
        }
    }
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

tasks.withType(Javadoc) {
    options.encoding = "UTF-8"
}

artifacts {
    archives javadocJar
    archives sourcesJar
}


