plugins {
    id("java")
    id("jacoco")

    id "com.github.fkorotkov.libraries" version "1.1"
}

updateLibraries.resolutionStrategy = {
    componentSelection { rules ->
        rules.all { ComponentSelection selection ->
            boolean rejected = ['dev', 'eap', 'M1', 'M2', 'M3'].any { qualifier ->
                selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
            }
            if (rejected) {
                selection.reject('dev version')
            }
        }
    }
}

subprojects {
    ext {
        current_k8s_dsl_version = System.getenv().getOrDefault(
          "VERSION",
          System.getenv().getOrDefault("CIRRUS_TAG", "2.0.0-SNAPSHOT")
        )
    }

    buildscript {
        repositories {
            maven { setUrl("https://repo.gradle.org/gradle/repo") }
            maven { setUrl("https://plugins.gradle.org/m2/") }
        }

        // put on the classpath but do not apply it
        dependencies {
            classpath libraries['org.jetbrains.kotlin:kotlin-gradle-plugin']
        }
    }
    repositories {
        mavenLocal()
        mavenCentral()
        google()
        maven { setUrl("https://repo.gradle.org/gradle/repo") }
        maven { setUrl("https://jitpack.io") }
        maven { setUrl("https://artifactory.cronapp.io/public-release") }
    }

    apply plugin: "com.fkorotkov.libraries"
    apply plugin: "java"
    apply plugin: "jacoco"

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    test {
        testLogging {
            exceptionFormat = 'full'
        }
    }

    jacocoTestReport {
        group = "Reporting"
        reports {
            xml.enabled true
            csv.enabled false
        }
    }
}
