plugins {
    id 'java'
}

group 'info.picocli'
description 'Picocli Annotation Processing Tests - Tests Annotation Processors for picocli Annotations.'
version "$projectVersion"
sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    implementation rootProject
    implementation project(':picocli-codegen')
    testImplementation "junit:junit:$junitVersion",
                       "com.google.testing.compile:compile-testing:$compileTestingVersion",
                       "org.apache.logging.log4j:log4j-api:2.17.1",
                       "org.apache.logging.log4j:log4j-core:2.17.1"

    if (org.gradle.api.JavaVersion.current().isJava8Compatible() && !org.gradle.api.JavaVersion.current().isJava9Compatible()) {
        // only use tools.jar on Java 8, it was removed in Java 9 // https://github.com/google/compile-testing/issues/134
        testImplementation files(org.gradle.internal.jvm.Jvm.current().getToolsJar()) // needed on Java 8: https://github.com/google/compile-testing/issues/102 (and #28)
    }
}
tasks.withType(Test.class) {
    if (org.gradle.api.JavaVersion.current().isJava12Compatible()) { // only a problem from Java 16, but okay
        it.jvmArgs '--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' // https://github.com/google/compile-testing/issues/222
    }
}

jar {
    manifest {
        attributes 'Specification-Title': 'Picocli Annotation Processing Tests',
                'Specification-Vendor'  : 'Remko Popma',
                'Specification-Version' : archiveVersion.get(),
                'Implementation-Title'  : 'Picocli Annotation Processing Tests',
                'Implementation-Vendor' : 'Remko Popma',
                'Implementation-Version': archiveVersion.get(),
                'Automatic-Module-Name' : 'info.picocli.annotation.processing.tests'
    }
}
