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

group = rootProject.ext.bintray['groupId']
version=rootProject.ext.android['versionName']

android {
    compileSdkVersion rootProject.ext.android.compileSdkVersion
    buildToolsVersion rootProject.ext.android.buildToolsVersion

    defaultConfig {
        minSdkVersion rootProject.ext.android.minSdkVersion
        targetSdkVersion rootProject.ext.android.targetSdkVersion
        versionCode rootProject.ext.android.versionCode
        versionName rootProject.ext.android.versionName
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compileOnly rootProject.ext.libs.appcompatV7
}


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
}

// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                name 'EasySwipeLayout-Core'
                groupId rootProject.ext.bintray['groupId']
                url rootProject.ext.bintray['siteUrl']
                artifactId 'core'
                description 'A simple sliding layout view.'
                licenses {
                    license {
                        name rootProject.ext.bintray['licenseName']
                        url rootProject.ext.bintray['licenseUrl']
                    }
                }
                developers {
                    developer {
                        id rootProject.ext.bintray['developerId']
                        name rootProject.ext.bintray['developerName']
                        email rootProject.ext.bintray['developerEmail']
                    }
                }
                scm {
                    connection rootProject.ext.bintray['gitUrl']
                    developerConnection rootProject.ext.bintray['gitUrl']
                    url rootProject.ext.bintray['siteUrl']
                }
            }
        }
    }
}

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

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

    configurations = ['archives']
    pkg {
        repo = 'maven-esl'
        name = 'core'
        desc = 'A simple sliding layout view.'
        websiteUrl = rootProject.ext.bintray['siteUrl']
        vcsUrl = rootProject.ext.bintray['gitUrl']
        licenses = rootProject.ext.allLicenses
        publish = true
    }
}