apply plugin: 'com.android.application'

android
{
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    sourceSets
    {
        main
        {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            java.srcDirs = ['src/main/java']
            res.srcDirs = ['src/main/res']
            assets.srcDirs = ['assets']
        }
    }

    defaultConfig
    {
        applicationId "com.forrestguice.suntimeswidget"
        //noinspection MinSdkTooLow
        minSdkVersion 14
        //noinspection ExpiredTargetSdkVersion,OldTargetApi
        targetSdkVersion 28
        versionCode 124
        versionName "0.16.10"

        buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

    lintOptions
    {
        disable 'MissingTranslation','WrongRegion','ObsoleteSdkInt'
    }

    useLibrary 'android.test.runner'
    useLibrary 'android.test.base'
    useLibrary 'android.test.mock'
}

dependencies
{
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:2.0.4'
    implementation 'android.arch.lifecycle:extensions:1.1.1'

    implementation group: 'net.time4j', name: 'time4j-android', version: '4.8-2021a'
    implementation project(path: ":lib-quadflask-colorpicker")    //implementation 'com.github.forrestguice:colorpicker:0.0.13post1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.jraska:falcon:2.2.0'
    androidTestImplementation 'com.android.support:support-annotations:28.0.0'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test:rules:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

def getGitHash()
{
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

tasks.withType(Test) 
{
    useJUnit {
        excludeCategories 'com.forrestguice.suntimeswidget.UnlistedTest', 'com.forrestguice.suntimeswidget.FlakeyTest'
    }
    testLogging 
    {
        exceptionFormat "full"
        //events "started", "skipped", "passed", "failed"
        //showStandardStreams true
        events "failed"
        showStandardStreams false
    }
}
