buildscript {
    repositories {
        mavenCentral()
        google()

//        jcenter reached end-of-life, but is required for MQTT until migrated.
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' // add plugin

        classpath 'com.google.gms:google-services:4.3.8' //added gms support
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.6.1'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter()

        maven { url "https://jitpack.io" }
    }
}
dependencies {
    //firebase
    implementation 'com.google.firebase:firebase-crashlytics:18.0.0'
    implementation 'com.google.firebase:firebase-analytics:19.0.0'
    implementation 'com.google.firebase:firebase-core:19.0.0'
    //google api
    implementation 'com.google.android.gms:play-services-base:17.6.0'
    implementation 'com.google.android.gms:play-services-basement:17.6.0'
    implementation 'com.google.android.gms:play-services-tasks:17.2.1'
    implementation 'com.google.android.gms:play-services-location:18.0.0'

    implementation 'com.google.android.gms:play-services-analytics:17.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.1'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    //greenDao
//    implementation 'org.roboguice:roboguice:4.0.0'
    implementation 'org.greenrobot:greendao:3.3.0'
    implementation 'org.greenrobot:greendao-generator:3.3.0'

    //COAP
    //implementation 'com.mbed.java-coap:coap-core:5.0.0' //original package
    implementation files('libs/coap-core-5.1.0-SNAPSHOT.jar') //forked repo https://github.com/irinil/java-coap

    //AMQP
    // https://mvnrepository.com/artifact/com.rabbitmq/amqp-client
    implementation group: 'com.rabbitmq', name: 'amqp-client', version: '5.12.0'

    implementation files('libs/qpid-broker-core-9.0.0-SNAPSHOT.jar') //forked repo https://github.com/irinil/qpid-broker-j
    //implementation group: 'org.apache.qpid', name: 'qpid-broker-core', version: '8.0.0' //default package doesn't support android.
    // https://mvnrepository.com/artifact/javax.naming/jndi
    implementation files('libs/jndi-1.2.1.jar');
    // https://mvnrepository.com/artifact/org.apache.qpid/qpid-broker-plugins-amqp-0-8-protocol
    implementation group: 'org.apache.qpid', name: 'qpid-broker-plugins-amqp-0-8-protocol', version: '8.0.4'
    // https://mvnrepository.com/artifact/org.apache.qpid/qpid-broker-plugins-amqp-1-0-protocol
    implementation group: 'org.apache.qpid', name: 'qpid-broker-plugins-amqp-1-0-protocol', version: '8.0.4'
    // https://mvnrepository.com/artifact/org.apache.qpid/qpid-broker-plugins-memory-store
    implementation group: 'org.apache.qpid', name: 'qpid-broker-plugins-memory-store', version: '8.0.4'

    //dependencies of AMQP broker
    // https://mvnrepository.com/artifact/com.google.guava/guava
    implementation group: 'com.google.guava', name: 'guava', version: '30.1.1-android'
    // https://mvnrepository.com/artifact/org.slf4j/slf4j-api
    implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
    // https://mvnrepository.com/artifact/joda-time/joda-time
    implementation group: 'joda-time', name: 'joda-time', version: '2.10.10' //for min <26 sdk
    //logback
    // https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
    implementation 'com.github.tony19:logback-android:2.0.0'

    //MQTT
    //moquette
    implementation 'io.moquette:moquette-broker:0.12.1'
    //hive-Mq
    implementation group: 'com.hivemq', name: 'hivemq-mqtt-client', version: '1.2.2'

    //SU Library for root
    implementation 'eu.chainfire:libsuperuser:1.0.0.201704021214'

    //RootTools Library
    implementation 'com.github.Stericson:RootShell:1.6' //RootTolls depends on RootShell and it's not correctly setUped for the jitpack
    implementation ('com.github.Stericson:RootTools:5.0') {//Refer to https://github.com/Stericson/RootTools/issues/65
        exclude group: 'com.github.Stericson'
    }

    implementation "androidx.constraintlayout:constraintlayout:2.0.4"

    //androidX legacy support
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.preference:preference:1.1.1'

    //other libraries
    implementation files('libs/sshlib-v1.1.jar')
    implementation files('libs/alfresco-jlan.jar')
    implementation files('libs/nineoldandroids-2.4.0.jar')
    implementation files('libs/cryptix-jce-provider.jar')
    implementation group: 'org.snmp4j', name: 'snmp4j', version: '3.4.5'
    // https://mvnrepository.com/artifact/org.snmp4j/snmp4j-agent
    implementation group: 'org.snmp4j', name: 'snmp4j-agent', version: '3.3.6'
    implementation files('libs/VirusTotalAPI.jar')
    implementation 'com.google.firebase:firebase-analytics:19.0.0'

    // https://mvnrepository.com/artifact/com.hierynomus/smbj
    testImplementation group: 'com.hierynomus', name: 'smbj', version: '0.11.1'

    // https://mvnrepository.com/artifact/commons-io/commons-io
    implementation group: 'commons-io', name: 'commons-io', version: '2.9.0'

    //device-Names
    implementation 'com.jaredrummler:android-device-names:2.0.0'

    //materialDesign
    implementation 'com.google.android.material:material:1.4.0-beta01'

    //leakcanary
    //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'

    // Required -- JUnit 4 framework
    testImplementation 'junit:junit:4.13.2'
    //testImplementation 'androidx.test:core:1.2.0'

    // Optional -- Mockito framework
    testImplementation "org.mockito:mockito-core:3.10.0"
    implementation 'androidx.annotation:annotation:1.0.0'

    androidTestImplementation 'androidx.test:rules:1.4.0-beta01'
    androidTestImplementation 'androidx.test:runner:1.4.0-beta01'

    // Optional -- UI testing with Espresso
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    //PowerMock
    testImplementation 'org.powermock:powermock-api-mockito2:2.0.9'
    testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
    testImplementation 'org.powermock:powermock-core:2.0.9'
    testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.9'
    implementation 'androidx.multidex:multidex:2.0.0'
    // Optional -- Robolectric environment
    testImplementation 'org.robolectric:robolectric:4.4.1'
}

greendao{
    schemaVersion 1
    //generateTests true
   // targetGenDir "src/db/"
}
//The first is for the conflict of common apache libraries between moquette and VirusTotalApi
//The second one is for the conflict with an older version of deprecated slf4j
configurations {
    all*.exclude group: 'commons-codec', module: 'commons-codec'
    all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}

android {
    compileSdkVersion 29
    defaultConfig {
        versionCode 11
        versionName "2.3.4"
        minSdkVersion 24
        targetSdkVersion 29
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }

        //   signingConfig signingConfigs.config

    }
    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }

    dexOptions {
        incremental true
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
    sourceSets {

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default hostage.location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }


    packagingOptions {
        pickFirst "META-INF/DEPENDENCIES"
        pickFirst "META-INF/INDEX.LIST"
        pickFirst "META-INF/io.netty.versions.properties"
    }
    // signing for release only works in the console
    boolean doSigningForRelease = System.console() != null
    if (doSigningForRelease) {
        signingConfigs {
            release {
                storeFile file(System.console().readLine("\n\$ Enter keystore path:  "))
                storePassword System.console().readLine("\n\$ Enter keystore password:  ")
                keyAlias System.console().readLine("\n\$ Enter key alias:  ")
                keyPassword System.console().readLine("\n\$ Enter key password:")
            }
        }
    }
    buildTypes {
        debug {
            debuggable true
            jniDebuggable true
//            testCoverageEnabled true
            //resValue "string", "google_maps_api_key", "AIzaSyDs3xp1-2KQojns5h7mWHHdQxAL-5AZ-q4"
        }
        if (doSigningForRelease) {
            release {
                debuggable false
                jniDebuggable false
                signingConfig signingConfigs.release
                //resValue "string", "google_maps_api_key", "AIzaSyDs3xp1-2KQojns5h7mWHHdQxAL-5AZ-q4"
            }
        }
        release {
//            signingConfig signingConfigs.config
        }
    }
    lintOptions {
        abortOnError false
    }
    productFlavors {
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}
