apply plugin: 'kotlin'
apply plugin: 'java-library'
apply plugin: 'jacoco'
apply from: '../gradle_scripts/code_quality.gradle'

sourceSets {
    main.java.srcDirs += "${projectDir}/src/main/kotlin"
    test.java.srcDirs += "${projectDir}/src/integrationTest/kotlin"
    test.resources.srcDirs += "${projectDir}/src/integrationTest/resources"
}

dependencies {
    api other.kotlinStdlib
    api other.retrofit
    implementation other.jacksonConverter
    implementation(other.jacksonKotlin) {
        exclude module: 'kotlin-reflect'
    }
    implementation other.kotlinReflect // for jackson kotlin, but to use the same version
    implementation other.okhttpLogging

    testImplementation testing.junit
    testImplementation testing.kotlinJunit
    testImplementation testing.mockitoKotlin
    testImplementation testing.kluent
    testImplementation testing.mockWebServer
    testImplementation testing.apacheCodecs
}

jacoco {
    toolVersion(versions.jacoco)
}

ext {
    // Excluding data classes
    jacocoExclude = [
            '**/models/**'
    ]
}

jacocoTestReport {
    reports {
        html.enabled true
        csv.enabled false
        xml.enabled true
    }

    afterEvaluate {
        classDirectories = files(classDirectories.files.collect {
            fileTree(dir: it, excludes: jacocoExclude)
        })
    }
}

test.finalizedBy jacocoTestReport
test {
    jacoco {
        excludes += jacocoExclude
    }
}