apply plugin: 'com.android.application'

//***********************************************************************************************//
def IOTHUB_CONNECTION_STRING_ENV_VAR_NAME = project.hasProperty('IOTHUB_CONNECTION_STRING') ? '"'+project.property('IOTHUB_CONNECTION_STRING')+'"' : '""'
def IOT_DPS_CONNECTION_STRING = project.hasProperty('IOT_DPS_CONNECTION_STRING') ? '"'+project.property('IOT_DPS_CONNECTION_STRING')+'"': '""'
def INVALID_DEVICE_PROVISIONING_SERVICE_GLOBAL_ENDPOINT = project.hasProperty('DPS_GLOBALDEVICEENDPOINT_INVALIDCERT') ? '"'+project.property('DPS_GLOBALDEVICEENDPOINT_INVALIDCERT')+'"': '""'
def INVALID_DEVICE_PROVISIONING_SERVICE_CONNECTION_STRING = project.hasProperty('PROVISIONING_CONNECTION_STRING_INVALIDCERT') ? '"'+project.property('PROVISIONING_CONNECTION_STRING_INVALIDCERT')+'"': '""'
def DEVICE_PROVISIONING_SERVICE_ID_SCOPE = project.hasProperty('IOT_DPS_ID_SCOPE') ? '"'+project.property('IOT_DPS_ID_SCOPE')+'"': '""'
def IS_BASIC_TIER_HUB = project.hasProperty('IS_BASIC_TIER_HUB') ? '"'+project.property('IS_BASIC_TIER_HUB')+'"' : '"false"'
def IS_PULL_REQUEST = project.hasProperty('IS_PULL_REQUEST') ? '"'+project.property('IS_PULL_REQUEST')+'"' : '"false"'
def RECYCLE_TEST_IDENTITIES = project.hasProperty('RECYCLE_TEST_IDENTITIES') ? '"'+project.property('RECYCLE_TEST_IDENTITIES')+'"' : '"false"'

def STRING='String'
//***********************************************************************************************//

android {
    compileSdkVersion 28

    defaultConfig {
        javaCompileOptions.annotationProcessorOptions.includeCompileClasspath true
        applicationId "com.iothub.azure.microsoft.com.androide2e"
        minSdkVersion 24
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        //********** We can define variables here **********
        each {
            //buildTypes.mBuildConfigFields 'DATATYPE','VARIABLE',|"GRADLE VARIABLE|"'
            buildConfigField STRING, 'IOTHUB_CONNECTION_STRING', IOTHUB_CONNECTION_STRING_ENV_VAR_NAME
            buildConfigField STRING, 'IOT_DPS_CONNECTION_STRING', IOT_DPS_CONNECTION_STRING
            buildConfigField STRING, 'DPS_GLOBALDEVICEENDPOINT_INVALIDCERT', INVALID_DEVICE_PROVISIONING_SERVICE_GLOBAL_ENDPOINT
            buildConfigField STRING, 'PROVISIONING_CONNECTION_STRING_INVALIDCERT', INVALID_DEVICE_PROVISIONING_SERVICE_CONNECTION_STRING
            buildConfigField STRING, 'IOT_DPS_ID_SCOPE', DEVICE_PROVISIONING_SERVICE_ID_SCOPE
            buildConfigField STRING, 'IS_BASIC_TIER_HUB', IS_BASIC_TIER_HUB
            buildConfigField STRING, 'IS_PULL_REQUEST', IS_PULL_REQUEST
            buildConfigField STRING, 'RECYCLE_TEST_IDENTITIES', RECYCLE_TEST_IDENTITIES
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude "META-INF/*.SF"
        exclude "META-INF/*.DSA"
        exclude "META-INF/*.RSA"
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'thirdpartynotice.txt'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions{
        ignore 'InvalidPackage'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:multidex:1.0.3'

    // This jar contains the test code that will be run on android. This jar isn't in the m2 folder, but rather it is in this cloned repo after mvn install is run
    implementation files('../../common/target/iot-e2e-common-1.0.0-tests.jar')

    // This jar contains the dependencies of the test code. DeviceClient, for instance. This jar isn't in the m2 folder, but rather it is in this cloned repo after mvn install is run
    implementation files('../../common/target/iot-e2e-common-1.0.0-with-deps.jar')

    implementation ('org.apache.commons:commons-lang3:3.6')
    implementation ('javax.xml.stream:stax-api:1.0-2')

    androidTestImplementation 'com.android.support:support-annotations:27.1.1'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'junit:junit:4.12'
}

repositories {
    mavenLocal()
    mavenCentral()
}