plugins {
    id 'java'
    id 'application'
    id("com.github.johnrengelman.shadow") version "8.1.1"
}

group = 'org.example'
version = '1.0'

allprojects {
    repositories {
        mavenCentral()
    }
}

dependencies {
    testImplementation platform('org.junit:junit-bom:5.10.0')
    testImplementation 'org.junit.jupiter:junit-jupiter'
    implementation project(':emu-core')
    implementation 'net.java.dev.jna:jna:5.15.0'
    implementation 'net.java.dev.jna:jna-platform:5.15.0'
    implementation files('emu-core/lib/libsdl4j.jar')
    implementation files('emu-core/lib/libsdl4j-2.24.0-1.0_mini.jar')
    implementation 'io.github.libsdl4j:libsdl4j:2.24.0-1.0'
    implementation 'com.formdev:flatlaf:3.6'
}

test {
    useJUnitPlatform()
}

application {
    mainClass = 'com.mygameapp.neoj2me.Main'
}

subprojects {
    apply plugin: 'java'
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

task copyNativeLibs(type: Copy) {
    from 'emu-core/lib/SDL2.dll'
    into 'build/libs'
}
tasks.withType(JavaCompile) {
    options.compilerArgs += "-Xlint:unchecked"
}

tasks.named('distTar').configure {
    dependsOn copyNativeLibs
}
tasks.named('distZip').configure {
    dependsOn copyNativeLibs
}
tasks.named('startScripts').configure {
    dependsOn copyNativeLibs
}