apply plugin: 'com.android.library'
apply plugin: 'com.github.kt3k.coveralls'
//apply plugin: 'jacoco'
apply plugin: 'jacoco-android'
apply plugin: 'kotlin-android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testHandleProfiling true
        testFunctionalTest true

        consumerProguardFiles 'proguard.txt'

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

    buildTypes {
        release {
            minifyEnabled false
        }
        debug {
            testCoverageEnabled true
        }
    }

    /*jacoco {
        version "0.7.5.201505241946"
    }*/

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    packagingOptions {
        exclude 'LICENSE.txt'
    }

    sourceSets {
        test.java.srcDirs += 'src/androidTest/kotlin'
    }
}

afterEvaluate {
    android.sourceSets.all { sourceSet ->
        if (!sourceSet.name.startsWith("androidTest")) {
            sourceSet.kotlin.setSrcDirs([])
        }
    }
}

dependencies {
    provided 'io.reactivex:rxjava:1.1.8'
    provided 'io.reactivex:rxandroid:1.2.1'

    compile 'com.esotericsoftware:kryo:4.0.0'//303

    androidTestCompile 'io.fabianterhorst:iron-encryption:0.4.1@aar'
    androidTestCompile 'com.orhanobut:hawk:1.14'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.squareup.assertj:assertj-android:1.0.0'
    androidTestCompile "org.jetbrains.kotlin:kotlin-stdlib:1.0.1-2"
}


coveralls {
    sourceDirs = files('iron/src/main/java').flatten()
    jacocoReportPath = "${buildDir}/reports/coverage/debug/report.xml"
}

/*def coverageSourceDirs = [
        'src/main/java',
]

task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."
    reports {
        xml.enabled = true
        html.enabled = true
    }
    classDirectories = fileTree(
            dir: './build/intermediates/classes/debug')
    sourceDirectories = files(coverageSourceDirs)
    executionData = files("$buildDir/jacoco/testDebug.exec")
    doFirst {
        new File("$buildDir/intermediates/classes/").eachFileRecurse { file ->
            if (file.name.contains('$$')) {
                file.renameTo(file.path.replace('$$', '$'))
            }
        }
    }
}*/

tasks.coveralls {
    dependsOn 'connectedAndroidTest'
    onlyIf { System.env.'CI' }
}


apply from: '../publish.gradle'
