apply plugin: 'com.android.library'

group = rootProject.ext.GROUP
version = rootProject.ext.VERSION_NAME

def gitSha() {
    return 'git rev-parse --short HEAD'.execute().text.trim()
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionName version

        buildConfigField "String", "LIBRARY_VERSION", "\"${rootProject.ext.VERSION_NAME}\""
        buildConfigField "String", "GIT_SHA", "\"${gitSha()}\""

//        consumerProguardFiles 'consumer-proguard-rules.pro', getDefaultProguardFile('proguard-rules.txt')
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }

    buildTypes {
        debug {
            // Run test code coverage reports by default on debug builds
            testCoverageEnabled = true
        }

        release {
            minifyEnabled true
        }
    }

    testOptions {
        // Allows Android code to be called from unit tests without causing a crash
        unitTests.returnDefaultValues = true
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    compileOnly 'com.android.support:support-annotations:27.1.1'
    compileOnly 'com.android.support.test.espresso:espresso-core:3.0.2'

    // Unit tests
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    testImplementation 'org.hamcrest:hamcrest-library:1.3'
}

//install {
//    repositories.mavenInstaller {
//        pom {
//            project {
//                groupId rootProject.ext.GROUP
//                artifactId POM_ARTIFACT_ID // in module's gradle.properties //'cappuccino'
//                packaging rootProject.ext.POM_PACKAGING //'aar'
//
//                name POM_NAME // in module's gradle.properties //"cappuccino"
//                url rootProject.ext.POM_URL //'https://github.com/metova/Cappuccino'
//
//                licenses {
//                    license {
//                        name rootProject.ext.POM_LICENSE_NAME //'The Apache Software License, Version 2.0'
//                        url rootProject.ext.POM_LICENSE_URL //'http://www.apache.org/licenses/LICENSE-2.0.txt'
//                        distribution rootProject.ext.POM_LICENSE_DIST
//                    }
//                }
//                developers {
//                    developer {
//                        id rootProject.ext.POM_DEVELOPER_ID//'trobalik'
//                        name rootProject.ext.POM_DEVELOPER_NAME//'Tony Robalik'
//                        email rootProject.ext.POM_DEVELOPER_EMAIL//'tony.robalik@metova.com'
//                    }
//                }
//                scm {
//                    connection rootProject.ext.POM_SCM_CONNECTION//'https://github.com/metova/Cappuccino.git'
//                    developerConnection rootProject.ext.POM_SCM_DEV_CONNECTION//'https://github.com/metova/Cappuccino.git'
//                    url rootProject.ext.POM_SCM_URL//'https://github.com/metova/Cappuccino'
//                }
//            }
//        }
//    }
//}
//
//task sourcesJar(type: Jar) {
//    from 'src/main/java'//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))
//    destinationDir = file("../javadoc/")
//    failOnError false
//}
//
//task javadocJar(type: Jar, dependsOn: javadoc) {
//    classifier = 'javadoc'
//    from javadoc.destinationDir
//}
//
//artifacts {
//    archives javadocJar
//    archives sourcesJar
//}

// Upload library to bintray
apply from: rootProject.file('gradle/gradle-bintray-install.gradle')
apply from: rootProject.file('gradle/gradle-bintray-upload.gradle')

apply from: rootProject.file('gradle/checkstyle-lib.gradle')
//apply from: rootProject.file('gradle/gradle-mvn-push.gradle')