buildscript {
    ext.kotlin_version = '1.3.10'

    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'idea'
apply plugin: 'kotlin'

sourceSets.main.java.srcDirs = ['src'] // because I'm not setting up proper /src/main/java/...

mainClassName = 'net.torvald.terrarum.AppLoader'

repositories {
    flatDir {
        dirs 'lib'
    }
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib"
    compile fileTree(dir: 'lib', include: ['*.jar'])
    implementation 'org.junit:junit-bom:5.2.0'
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

jar {
    baseName = 'Terrarum'
    version = '0.2'
}

// should be same as plain old 'gradlew run'
task game(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath
    main = 'net.torvald.terrarum.AppLoader'
    group = "Application"
    description = "Launches the game. Should be the same as 'gradlew run'"
}

task gamedebug(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath
    main = 'net.torvald.terrarum.AppLoader'
    group = "Application"
    description = "Launches the game with the debug key"
    args = ["isdev=true"]
    jvmArgs = ["-ea"] // make assert functions work
}

task spriteassembler(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath
    main = 'net.torvald.spriteassembler.SpriteAssemblerAppKt'
    group = "Application"
    description = "Launches the Sprite Assembler"
}

task csveditor(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath
    main = 'net.torvald.terrarum.debuggerapp.CSVEditor'
    group = "Application"
    description = "Launches the CSV Editor for in-game Blocks"
}
