plugins {
    id 'com.jfrog.bintray' version '1.7.3'
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

group = 'com.filestack'
version = '6.0.0'
project.archivesBaseName = 'filestack-android'

android {
    compileSdkVersion 33

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 33
        multiDexEnabled = true

        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

        vectorDrawables {
            useSupportLibrary true
        }

        resourcePrefix 'filestack__'
        buildConfigField "String", "FILESTACK_ANDROID_VERSION", "\"$version\""

    }
    buildTypes {
        release {
            minifyEnabled false
            consumerProguardFile 'consumer-proguard-rules.pro'
        }
    }
}

dependencies {
    api 'com.filestack:filestack-java:0.9.0'

    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.browser:browser:1.0.0'
    
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'

    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
    testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    options.addStringOption('Xdoclint:none', '-quiet')
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    destinationDir = file("../docs/")
}

// Add dependencies to javadoc classpath so annotations work
afterEvaluate {
    javadoc.classpath += files(android.libraryVariants.collect { variant ->
        variant.javaCompiler.classpath.files
    })
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

bintray {
    user = project.hasProperty('bintrayUser') ? project.property('bintrayUser')
            : System.getenv('BINTRAY_USER')
    key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey')
            : System.getenv('BINTRAY_API_KEY')
    configurations = ['archives']
    publish = true
    pkg {
        repo = 'maven'
        userOrg = 'filestack'
        name = 'filestack-android'
        desc = 'Official Android SDK for Filestack.'

        publicDownloadNumbers = true
        licenses = ['Apache-2.0']

        websiteUrl = 'https://filestack.com'
        vcsUrl = 'https://github.com/filestack/filestack-android.git'
        issueTrackerUrl = 'https://github.com/filestack/filestack-android/issues'

        githubRepo = 'filestack/filestack-android'
        githubReleaseNotesFile = 'CHANGELOG.md'

        version {
            name = project.version
            vcsTag = project.version
            released = new Date()
        }
    }
}
