/**
*   Contains gradle configuration constants
*/
ext {
    PSPDFKIT_VERSION = '6.0.2'
}

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
    }
}

def demoVersion = false;
project.repositories.each {
    if (it instanceof MavenArtifactRepository) {
        if ("$it.url".contains("customers.pspdfkit.com/maven")) {
            // Bug: https://github.com/gradle/gradle/issues/1230
            def username = it.credentials.username
            def password = it.credentials.password

            if (username == "pspdfkit") {
                if (password != null && password.startsWith("TRIAL")) {
                    demoVersion = true;
                } else if (password != null && password == "YOUR_MAVEN_PASSWORD_GOES_HERE") {
                    println "#######################################################################################################"
                    println "### Credentials error: edit 'YourApp/android/build.gradle' file and modify PSPDFKit maven password. ###"
                    println "#######################################################################################################"
                }
            }
        }
    }
}

if (demoVersion) {
    println "##############################"
    println "### PSPDFKit Demo Version. ###"
    println "##############################"
}

dependencies {
    compile("com.pspdfkit:pspdfkit:${PSPDFKIT_VERSION}") {
        exclude group: 'com.google.auto.value', module: 'auto-value'
    }
    compile "com.facebook.react:react-native:+"
}
