apply plugin: "java"

dependencies {
    implementation project(":core")
    implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
    implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
    implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
    implementation "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"
    implementation "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
}
sourceSets.main.java.srcDirs = [ "src/" ]

project.ext.mainClassName = "com.agateau.pixelwheels.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../android/assets")

task run(dependsOn: classes, type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
}

task dist(type: Jar) {
    from files(sourceSets.main.output.classesDirs)
    from files(sourceSets.main.output.resourcesDir)
    from {configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
    from files(project.assetsDir)

    manifest {
        attributes 'Main-Class': project.mainClassName
    }
    // Required to fix this error after updating to Gradle 7.3.3:
    // Entry META-INF/INDEX.LIST is a duplicate but no duplicate handling strategy has been set.
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

dist.dependsOn classes
