apply plugin: 'java'
apply plugin: 'maven-publish'

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

archivesBaseName = 'carballo-jse'

dependencies {
    implementation project(':core')
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
}

task proguard(type: proguard.gradle.ProGuardTask) {
    dependsOn('jar')
    ext {
        obfuscatedJar = "./carballo-${version}.jar"
    }
    injars jar.archiveFile.get()
    injars configurations.runtimeClasspath
    outjars ext.obfuscatedJar
    libraryjars "${System.getProperty('java.home')}/jmods"
    optimizationpasses 5
    allowaccessmodification()
    dontskipnonpubliclibraryclassmembers()
    target '11'
    keep 'public class com.alonsoruibal.chess.uci.Uci { *; }'
    keep 'public class EpdTest { *; }'
    doLast {
        logger.lifecycle "[Proguard] Generated obfuscated JAR in ${ext.obfuscatedJar}"
    }
}

jar {
    manifest.attributes("Main-Class": "com.alonsoruibal.chess.uci.Uci")
}

test {
    ignoreFailures = true
    enableAssertions = true

    useJUnitPlatform {
        excludeTags 'slow'
    }
}

task slowTest(type: Test) {
    ignoreFailures = true
    enableAssertions = true

    useJUnitPlatform {
        includeTags 'slow'
    }
}

publishing {
    publications {
        carballoJse(MavenPublication) {
            from components.java
            artifactId = 'carballo-jse'
        }
    }
}
