/********************************************************************************
 * Copyright (c) 2023 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 ********************************************************************************/
apply from: "$rootDir/gradle/base.gradle"

apply plugin: 'java'
apply plugin: 'jacoco'

def lombok_version = "1.18.22"
dependencies {
    implementation 'org.slf4j:slf4j-api:2.0.7'

    compileOnly "org.projectlombok:lombok:$lombok_version"
    annotationProcessor "org.projectlombok:lombok:$lombok_version"

    testCompileOnly "org.projectlombok:lombok:$lombok_version"
    testAnnotationProcessor "org.projectlombok:lombok:$lombok_version"

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'

    testImplementation 'org.mockito:mockito-junit-jupiter:4.8.1'
    testRuntimeOnly 'org.mockito:mockito-core:4.8.1'
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

[compileJava, compileTestJava].each { compile ->
    compile.options.encoding = "UTF-8"

    compile.options.compilerArgs << '-Xlint:unchecked'
    compile.options.compilerArgs << "-Xlint:deprecation"
    compile.options.compilerArgs << '-parameters'
}

def testTempPath = rootProject.projectDir.toPath().toAbsolutePath().resolve('.test-temp')
delete testTempPath.toFile()
testTempPath.toFile().mkdir()

test {
    testLogging.showStandardStreams = true
    useJUnitPlatform()

    systemProperty 'java.io.tmpdir', testTempPath.toString()
    systemProperty 'jdk.util.zip.disableZip64ExtraFieldValidation', true

    finalizedBy jacocoTestReport
}

jacocoTestReport {
    dependsOn test
}