plugins {
    id "com.jfrog.bintray" version "1.7.3"
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

String projectVersion = "1.0.5"
String projectGroup = "ru.egslava"

version = projectVersion
group = projectGroup

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'


    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName projectVersion
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

dependencies {
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

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

    testCompile 'junit:junit:4.12'
}


// bintray deploy ....
String projectName = "edittext-mask"
String projectDescription = GFileUtils.readFile(new File("README.md"))
String webUrl = "https://github.com/egslava/edittext-mask"
String gitUrl = "https://github.com/egslava/edittext-mask.git"


install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                
                name projectName
                description projectDescription
                url webUrl

                inceptionYear '2017' // HARDCODED

                licenses {
                    license {
                        name 'MIT'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution 'repo'
                    }
                }

                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url webUrl
                }
                developers {
                    developer {
                        id 'egslava'
                        name 'Slava Egorenkov'
                        email 'egslava@gmail.com'
                    }
                }
            }
        }
    }
}

// The end of the gradle file is for JCenter publication.
// The original code was written with look at Alexander Matveychuk's code
// and
// https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/

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

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

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

bintray {
    user = bintrayUser
    key = bintrayApikey

    configurations = ['archives']
    pkg {
        repo = "maven"
        name = projectName
        userOrg = user
//        projectUrl = webUrl
        vcsUrl = gitUrl
        licenses = ["MIT"]
        group = projectGroup
        publish = true

        version {
            name = projectVersion
//            desc = projectDescription
            vcsTag = projectVersion
        }
    }
}