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

archivesBaseName = 'Isometric'

project.screenshots.customTestRunner = true

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 9
        versionName "0.0.9"
        testInstrumentationRunner 'io.fabianterhorst.isometric.screenshot.IsometricTestRunner'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            defaultConfig {
                targetSdkVersion 28
            }
        }
        debug {
            defaultConfig {
                targetSdkVersion 21
            }
        }
    }
}

def siteUrl = 'https://github.com/FabianTerhorst/Isometric'
def gitUrl = 'https://github.com/FabianTerhorst/Isometric.git'

version = "0.0.9"
group = "io.fabianterhorst"

install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            //noinspection GroovyAssignabilityCheck
            project {
                packaging 'aar'

                // Add your description here
                name 'Isometric'
                description 'Isometric drawing library for Android'
                url siteUrl

                // Set your license
                licenses {
                    license {
                        name 'The Apache License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution 'repo'
                    }
                }
                developers {
                    developer {
                        id 'fabianterhorst'
                        name 'Fabian Terhorst'
                        email 'fabian.terhorst@gmail.com'
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl
                }
            }
        }
    }
}

Properties properties = new Properties()
try {
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
} catch (Exception ignore) {
}

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = 'maven'
        name = 'Isometric'
        userOrg = user
        licenses = ['Apache-2.0']
        vcsUrl = 'https://github.com/FabianTerhorst/Isometric.git'
        publish = true
    }
}

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
    // options.encoding = 'UTF-8'
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

dependencies {
    compileOnly 'androidx.annotation:annotation:1.0.0'
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.robolectric:robolectric:3.8'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-beta02', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
}
