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

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'


    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 26
        versionCode 1
        versionName "1.1"

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

    }

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

}

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

}

//bintray {
//    user = 'dirkvranckaert'
//    key = 'c71fea0ea2460f4a157972d22235e38038e57b21'
//    // bintray.user and bintray.key in local.properties
//    pkg {
//        repo = 'generic'
//        name = 'eu.vranckaert.touch'
//        userOrg = 'dirkvranckaert'
//        licenses = ['GPL-3.0']
//        vcsUrl = 'https://github.com/dirkvranckaert/touchinputdisplaydriver.git'
//        configurations = ['archives']
//        version {
//            name = '1.0'
//            desc = 'Touch input display driver for Android Touch'
//            released  = new Date()
//            vcsTag = '1.0'
//            attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
//        }
//    }
//}

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
}

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

def siteUrl = 'https://github.com/dirkvranckaert/touchinputdisplaydriver'      // Homepage URL of the library
def gitUrl = 'https://github.com/dirkvranckaert/touchinputdisplaydriver.git'   // Git repository URL
group = "eu.vranckaert.driver"                      // Maven Group ID for the artifact
project.version = "1.1.0"

//install {
//    repositories.mavenInstaller {
//        pom.project {
//            packaging 'aar'
//            groupId 'eu.vranckaert.driver'
//            artifactId 'touch'
//            version project.version
//            name 'TouchScreenDriver'
//            url 'https://github.com/dirkvranckaert/touchinputdisplaydriver'
//            inceptionYear '2017'
//            licenses {
//                license {
//                    name 'GPL-3.0'
//                    url 'https://www.gnu.org/licenses/gpl.txt'
//                    distribution 'repo'
//                }
//            }
//            scm {
//                connection 'https://github.com/dirkvranckaert/touchinputdisplaydriver.git'
//                developerConnection 'https://github.com/dirkvranckaert/touchinputdisplaydriver.git'
//                url 'https://github.com/dirkvranckaert/touchinputdisplaydriver'
//            }
//        }
//    }
//}

// https://github.com/bintray/gradle-bintray-plugin
bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")

    configurations = ['archives']
    pkg {
        repo = "maven"
        // it is the name that appears in bintray when logged
        name = "TouchScreenDriver"
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["GPL-3.0"]
        publish = true
        version {
            name = project.version
            desc = 'Touch input display driver for Android Touch'
            released  = new Date()
            vcsTag = project.version
            gpg {
                sign = true //Determines whether to GPG sign the files. The default is false
                passphrase = properties.getProperty("bintray.gpg.passphrase")
            }
        }
    }
}