description = 'Runs examples, includes the code and the output in README.md'

repositories {
    maven { url "https://dl.bintray.com/jetbrains/spek" }
}

apply plugin: 'kotlin'
dependencies {
    implementation "org.junit.platform:junit-platform-console-standalone:$junit_platform_version"
    implementation "org.spekframework.spek2:spek-dsl-jvm:$spek2_version"
    implementation "org.spekframework.spek2:spek-runner-junit5:$spek2_version"
    implementation "org.spekframework.spek2:spek-runtime-jvm:$spek2_version"
    runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

    implementation kotlinStdlib()
    implementation prefixedProject('fluent-en_GB-jvm')
    implementation prefixedProject('core-robstoll-lib-jvm')
    implementation niok()
    implementation spekExtensions()
}

compileKotlin {
    kotlinOptions.languageVersion = '1.3'
}

def readme = task("readme", type: JavaExec, group: 'documentation') {
    description = "Runs examples, includes the code and the output in README.md"

    classpath sourceSets.main.runtimeClasspath
    environment "README_SOURCETREE", dokka_sourceMapping

    main = 'org.junit.platform.console.ConsoleLauncher'
    args = [
        '--scan-class-path', sourceSets['main'].output.classesDirs.asPath,
        '--disable-banner',
        '--fail-if-no-tests',
        '--include-engine', 'spek2-readme',
        '--details', 'summary'
    ]
}

check.dependsOn(readme)
