//for jar packaging see https://github.com/Protonull/BasicMinestomServer/blob/master/build.gradle.kts

plugins {
    id 'java'
    id "com.github.johnrengelman.shadow" version "7.1.0"
}

group 'eu.mhsl.minenet'
version '1.0-SNAPSHOT'

repositories {
    //maven 'https://repo.unnamed.team/repository/unnamed-public/'

    mavenCentral()
    google()

    maven {
        url 'https://jitpack.io'
    }

    maven {
        url "https://repo.unnamed.team/repository/unnamed-public/"
    }

    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots'
    }
}

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}


java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21)
    }
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'

    //https://jitpack.io/#Minestom/Minestom
    implementation 'net.minestom:minestom-snapshots:d707b0674f'

    //Tools
    implementation 'de.articdive:jnoise:3.0.2'
    implementation 'net.md-5:bungeecord-config:1.19-R0.1-SNAPSHOT'
    implementation 'org.apache.commons:commons-text:1.10.0'
    implementation 'org.spongepowered:configurate-yaml:4.1.2'
    implementation 'com.sparkjava:spark-core:2.9.4'
    implementation 'com.google.code.gson:gson:2.10.1'
    implementation 'com.google.guava:guava:32.0.0-android'


    //PvP
    implementation 'com.github.TogAr2:MinestomPvP:04180ddf9a'

    // Hephaestus engine
    implementation("team.unnamed:hephaestus-api:0.2.1-SNAPSHOT")
    implementation("team.unnamed:hephaestus-reader-blockbench:0.2.1-SNAPSHOT")
    implementation("team.unnamed:hephaestus-runtime-minestom:0.2.1-SNAPSHOT")
}

tasks {
    jar {
        manifest {
            attributes 'Main-Class': 'eu.mhsl.minenet.minigames.Main'
            attributes 'Multi-Release': true
        }
        duplicatesStrategy = 'exclude'
        from configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    build {
        dependsOn(shadowJar)
    }
    shadowJar {
        mergeServiceFiles()
        archiveClassifier.set("")
    }
}

tasks.register('copyJarToServer', Exec) {
    dependsOn shadowJar
    mustRunAfter shadowJar

    commandLine 'scp', 'build/libs/Minigames-1.0-SNAPSHOT.jar', 'root@10.20.6.5:/root/minigames'
}