/*
 * Nextcloud Talk application
 *
 * @author Mario Danic
 * Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'findbugs'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
    apply from: 'gplay.gradle'
}

android {
    compileSdkVersion 29
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.nextcloud.talk2"
        minSdkVersion 21
        targetSdkVersion 29
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        // mayor.minor.hotfix.increment (for increment: 1-50=Alpha / 51-89=RC / 90-99=stable)
        // xx   .xxx  .xx    .xx
        versionCode 120000005
        versionName "12.0.0 Alpha 05"

        flavorDimensions "default"
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true

        productFlavors {
            // used for f-droid
            generic
            gplay

        }

        // Enabling multidex support.
        multiDexEnabled true

        vectorDrawables.useSupportLibrary = true

        lintOptions {
            disable 'InvalidPackage'
            disable 'MissingTranslation'
        }

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        parcelerStacktrace: "true"
                ]
            }
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

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

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/rxjava.properties'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
        htmlReport true
        htmlOutput file("$project.buildDir/reports/lint/lint.html")
        disable 'MissingTranslation'
    }

    task findbugs(type: FindBugs) {
        ignoreFailures = false
        effort = "max"
        reportLevel = "medium"
        classes = fileTree("${project.rootDir}/app/build/intermediates/javac/gplayDebug/classes/com/nextcloud/")
        excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
        source = fileTree('src/main/java')
        pluginClasspath = project.configurations.findbugsPlugins
        classpath = files()
        include '**/*.java'
        exclude '**/gen/**'

        reports {
            xml.enabled = false
            html.enabled = true
            html {
                destination = file("$project.buildDir/reports/findbugs/findbugs.html")
            }
        }
    }
}

ext {
    workVersion = "1.0.1"
}


configurations.all {
    exclude group: 'com.google.firebase', module: 'firebase-core'
    exclude group: 'com.google.firebase', module: 'firebase-analytics'
    exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
}


dependencies {
    implementation fileTree(include: ['*'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.2.0-alpha01'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
    implementation 'com.github.vanniktech:Emoji:0.6.0'
    implementation group: 'androidx.emoji', name: 'emoji-bundled', version: '1.0.0'
    implementation 'org.michaelevans.colorart:library:0.0.3'
    implementation "android.arch.work:work-runtime:${workVersion}"
    implementation "android.arch.work:work-rxjava2:${workVersion}"
    implementation 'com.google.android:flexbox:1.1.0'
    androidTestImplementation "android.arch.work:work-testing:${workVersion}"
    implementation ('com.gitlab.bitfireAT:dav4jvm:f2078bc846', {
        exclude group: 'org.ogce', module: 'xpp3'	// Android comes with its own XmlPullParser
    })
    implementation 'org.conscrypt:conscrypt-android:2.5.1'


    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

    implementation 'androidx.biometric:biometric:1.0.1'
    implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"

    implementation 'androidx.multidex:multidex:2.0.1'

    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation "io.reactivex.rxjava2:rxjava:2.2.11"

    implementation 'com.bluelinelabs:conductor:2.1.5'
    implementation 'com.bluelinelabs:conductor-support:2.1.5'

    implementation 'com.squareup.okhttp3:okhttp:3.14.2'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.14.2'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.14.2'

    implementation 'com.bluelinelabs:logansquare:1.3.7'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.10.1'
    kapt 'com.bluelinelabs:logansquare-compiler:1.3.7'

    implementation 'com.squareup.retrofit2:retrofit:2.7.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
    implementation 'com.github.aurae.retrofit2:converter-logansquare:1.4.1'

    implementation 'com.google.dagger:dagger:2.24'
    kapt 'com.google.dagger:dagger-compiler:2.24'
    implementation 'com.github.lukaspili.autodagger2:autodagger2:1.1'
    kapt 'com.github.lukaspili.autodagger2:autodagger2-compiler:1.1'
    compileOnly 'javax.annotation:jsr250-api:1.0'
    // Android only
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'io.requery:requery:1.5.1'
    implementation 'io.requery:requery-android:1.6.1'
    implementation 'net.zetetic:android-database-sqlcipher:3.5.9'
    kapt 'io.requery:requery-processor:1.6.1'
    implementation 'org.parceler:parceler-api:1.1.12'
    kapt 'org.parceler:parceler:1.1.12'
    implementation 'net.orange-box.storebox:storebox-lib:1.4.0'
    compileOnly 'org.projectlombok:lombok:1.18.10'
    annotationProcessor "org.projectlombok:lombok:1.18.10"
    implementation 'com.jakewharton:butterknife:10.2.3'
    kapt 'com.jakewharton:butterknife-compiler:10.2.1'
    implementation 'com.github.HITGIF:TextFieldBoxes:1.4.5'
    implementation 'eu.davidea:flexible-adapter:5.1.0'
    implementation 'eu.davidea:flexible-adapter-ui:1.0.0'
    implementation 'org.webrtc:google-webrtc:1.0.32006'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
    implementation 'com.yarolegovich:lovely-dialog:1.1.0'
    implementation 'com.yarolegovich:lovelyinput:1.0.9'
    implementation 'com.yarolegovich:mp:1.0.9'
    implementation 'me.zhanghai.android.effortlesspermissions:library:1.1.0'
    implementation 'org.apache.commons:commons-lang3:3.11'
    implementation 'com.github.wooplr:Spotlight:1.3'
    implementation 'com.google.code.findbugs:jsr305:2.0.1'
    implementation('com.github.mario:chatkit:c6a61767291ddb212a2f4f792a2b6aaf295e69a5', {
        exclude group: 'com.facebook.fresco'
    })

    implementation 'com.github.mario.fresco:fresco:111'
    implementation 'com.github.mario.fresco:animated-webp:111'
    implementation 'com.github.mario.fresco:webpsupport:111'
    implementation 'com.github.mario.fresco:animated-gif:111'
    implementation 'com.github.mario.fresco:imagepipeline-okhttp3:111'
    implementation  group: 'joda-time', name: 'joda-time', version: '2.10.3'
    implementation 'io.coil-kt:coil:0.9.1'
    implementation("io.coil-kt:coil-gif:0.9.1")
    implementation("io.coil-kt:coil-svg:0.9.1")
    implementation 'com.github.natario1:Autocomplete:v1.1.0'

    implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:2.4.5'

    implementation 'com.novoda:merlin:1.2.1'

    implementation 'com.github.Kennyc1012:BottomSheet:2.4.1'
    implementation 'com.github.mario:PopupBubble:a365177d96'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'eu.medsea.mimeutil:mime-util:2.1.3'

    implementation 'com.afollestad.material-dialogs:core:3.1.0'
    implementation 'com.afollestad.material-dialogs:datetime:3.1.0'
    implementation 'com.afollestad.material-dialogs:bottomsheets:3.1.0'
    implementation 'com.afollestad.material-dialogs:lifecycle:3.1.0'

    implementation 'com.google.code.gson:gson:2.8.6'

    testImplementation 'junit:junit:4.13'
    testImplementation 'org.mockito:mockito-core:3.0.0'
    testImplementation 'org.powermock:powermock-core:2.0.2'
    testImplementation 'org.powermock:powermock-module-junit4:2.0.2'
    testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'

    androidTestImplementation ('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
    findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.6'
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}