buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }

    dependencies {
        classpath "io.freefair.gradle:lombok-plugin:$gradlePluginLombokVersion"
        classpath "com.github.ben-manes:gradle-versions-plugin:$gradlePluginVersionsVersion"
        classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:$licenseGradlePluginVersion"
    }
}

allprojects {
    group = "$groupPackage"
    version = "$projectVersion"
}

subprojects {

    apply plugin: "signing"
    apply plugin: "java"
    apply plugin: "jacoco"
    apply plugin: "maven-publish"
    apply plugin: "com.github.ben-manes.versions"
    apply plugin: "com.github.hierynomus.license"

    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        compileOnly("org.projectlombok:lombok:$lombokVersion")
        annotationProcessor("org.projectlombok:lombok:$lombokVersion")
        testImplementation("de.alpharogroup:test-objects:$testObjectsVersion")
        testImplementation("de.alpharogroup:silly-collections:$sillyCollectionsVersion")
        testImplementation("de.alpharogroup:silly-beans:$sillyBeansVersion")
        testImplementation("de.alpharogroup:jobj-contract-verifier:$jobjContractVerifierVersion")
        testImplementation("org.meanbean:meanbean:$meanbeanVersion")
        testImplementation("org.testng:testng:$testngVersion")
    }

    // workhack for license issue #76
    gradle.startParameter.excludedTaskNames += "licenseMain"
    gradle.startParameter.excludedTaskNames += "licenseTest"

    sourceCompatibility = "$projectSourceCompatibility"

    javadoc {
        if (JavaVersion.current().isJava9Compatible()) {
            options.addBooleanOption("html5", true)
        }
    }

    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
    }

    test {
        useTestNG()
    }

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

    check.dependsOn jacocoTestReport
}
