import org.gradle.internal.jvm.Jvm

plugins {
    id "org.jetbrains.kotlin.jvm"
    id "org.jetbrains.kotlin.kapt"
    id "org.jlleitschuh.gradle.ktlint"
}

apply from: "$SUB_PROJECT"
apply from: "$DOC_CREATION"
apply from: "$PUBLICATION"

dependencies {
    api project(':arrow-annotations')
    api "io.arrow-kt:kotlin-metadata:$KOTLIN_METADATA_VERSION"
    api("com.squareup:kotlinpoet:$KOTLIN_POET_VERSION") {
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect'
    }
    api "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"
    compileOnly "com.google.auto.service:auto-service:$GOOGLE_AUTO_SERVICE_VERSION"
    kapt "com.google.auto.service:auto-service:$GOOGLE_AUTO_SERVICE_VERSION"

    //To generate stubs for data classes
    kaptTest "com.google.auto.service:auto-service:$GOOGLE_AUTO_SERVICE_VERSION"
    testCompileOnly "com.google.testing.compile:compile-testing:$GOOGLE_COMPILE_TESTING_VERSION"
    testCompileOnly fileTree(dir: './src/test/libs', includes: ['*.jar'])
    testCompileOnly project(":arrow-meta:arrow-meta-test-models")
    testCompileOnly("junit:junit:$JUNIT_VERSION")
    testRuntimeOnly("org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION")
    testImplementation "io.kotlintest:kotlintest-runner-junit4:$KOTLIN_TEST_VERSION", excludeArrow
    def toolsJar = Jvm.current().getToolsJar()

    if (!toolsJar)
        throw new GradleException("tools.jar not found at your JAVA_HOME dir ${Jvm.current().getJavaHome().getAbsolutePath()}.\n" +
                "Building with a JRE or JDK9 is currently not supported.")
    testCompileOnly files(toolsJar)
}
