import org.gradle.internal.jvm.Jvm

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: "com.vanniktech.maven.publish"

sourceCompatibility = rootProject.JAVA_SOURCE_VERSION
targetCompatibility = rootProject.JAVA_TARGET_VERSION

dependencies {
    implementation project(':paris-annotations')
    implementation deps.ksp
    implementation deps.kspImpl
    implementation deps.xProcessing
    // Compiler needed to resolve resource references in annotations
    implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:$KOTLIN_VERSION"

    implementation deps.androidAnnotations

    compileOnly deps.incapRuntime
    kapt deps.incapProcessor

    compileOnly files(rootProject.file("libs/tools.jar"))

    testImplementation deps.xProcessingTesting
    testImplementation deps.junit
    testImplementation "io.strikt:strikt-core:0.34.1"
    testImplementation deps.kotlinTest
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    kotlinOptions {
        jvmTarget = "11"
        freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
        freeCompilerArgs += "-Xopt-in=kotlin.contracts.ExperimentalContracts"
        freeCompilerArgs += "-Xopt-in=androidx.room.compiler.processing.ExperimentalProcessingApi"
        freeCompilerArgs += "-Xopt-in=com.google.devtools.ksp.KspExperimental"
    }
}

tasks.withType(Test) {
    jvmArgs(
        '--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
        '--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
    )
}
