plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.4.32'
    id 'edu.sc.seis.launch4j' version '2.5.0'
}

group 'org.rs09'
version '1.1'

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    implementation 'org.jsoup:jsoup:1.14.1'
    implementation files("libs/json-simple-1.1.1.jar")
}

jar {
    manifest {
        attributes 'Main-Class': 'MainWindow'
    }
    from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
}

launch4j {
    mainClassName = "MainWindow"
    icon = "${projectDir}/src/main/resources/09logo.ico"
    jarTask = project.tasks.jar
    bundledJre64Bit = false
    bundledJrePath = "jre"
    downloadUrl = "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jre_x86-32_windows_hotspot_8u292b10.msi"
    outfile = "2009scape.exe"
    copyright = "2009scape"
    companyName = "2009scape"
}

task packageExecutableDistribution(type: Zip) {
    archiveName = "2009scape.zip"
    destinationDir = file("$buildDir/distExecutable")

    from "$buildDir/launch4j"
}

task addJreToDistributable(type: Copy) {
    from files("${projectDir}/launch4j")
    destinationDir = file("$buildDir/launch4j")
}

packageExecutableDistribution.dependsOn createExe
packageExecutableDistribution.dependsOn addJreToDistributable