plugins {
    id 'java'
    id "net.ltgt.errorprone" version "4.3.0"
}

repositories {
    mavenCentral()
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(rootProject.java_version as Integer)
    }
}

/* Expose the JDK internal packages. */
tasks.named('compileJava') {
    options.release.set(null)
    options.compilerArgs += [
        "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
        "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
        "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
    ]
}

dependencies {
    /* Use error-prone to write our custom checkers. */
    errorprone("com.google.errorprone:error_prone_core:${project.errorprone_version}")
    implementation("com.google.errorprone:error_prone_core:${project.errorprone_version}")

    /* Use auto-service to generate the services meta information. */
    annotationProcessor("com.google.auto.service:auto-service:${project.autoservice_version}")

    /* Use lombok. */
    compileOnly "org.projectlombok:lombok:${project.lombok_version}"
    annotationProcessor "org.projectlombok:lombok:${project.lombok_version}"
    testCompileOnly "org.projectlombok:lombok:${project.lombok_version}"
    testAnnotationProcessor "org.projectlombok:lombok:${project.lombok_version}"
}